8 Replies Latest reply: Jan 3, 2013 5:51 AM by EJP RSS

    Static initailizers

    880368
      Here is some code:

      public class A {



      public void method1() {


      .....
      for (IHandlerStrategy strategy : IStrategyContext.fileStrategies) {
      //     do some process                    
      }

      ....

      }



      public class IStrategyContext {

           public static List<IHandlerStrategy> fileStrategies;
      public static List<IHandlerStrategy> instStrategies;


           static {
      instStrategies.add(new Inst1());
                instStrategies.add(new Inst2());

                for(IlHandlerStrategy instStrategy:instStrategies)
                {
                     fileStrategies.add(instStrategy);
                }
      }
      }


      It gives me java.lang.reflect.InvocationTargetException at for (IHandlerStrategy strategy : IStrategyContext.fileStrategies) {

      Can someone guide me as to how to resolve the problem. Thank you.