]> source.dussan.org Git - aspectj.git/commitdiff
use new targeter set rather than array
authoraclement <aclement>
Thu, 28 Aug 2008 02:06:43 +0000 (02:06 +0000)
committeraclement <aclement>
Thu, 28 Aug 2008 02:06:43 +0000 (02:06 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java

index 39094344e1bbc49ae58d8e60262df5341056a88c..27727a7b4c2b8da623ed18e92c85b57180a0ac99 100644 (file)
@@ -1537,7 +1537,7 @@ class BcelClassWeaver implements IClassWeaver {
                                                InstructionHandle monitorExitBlockStart = body.insert(element,monitorExitBlock);
                                                
                                                // now move the targeters from the RET to the start of the monitorexit block
-                                               InstructionTargeter[] targeters = element.getTargeters();
+                                               InstructionTargeter[] targeters = element.getTargetersArray();
                                                if (targeters!=null) {
                                                        for (int i = 0; i < targeters.length; i++) {
                                                
@@ -1717,7 +1717,7 @@ class BcelClassWeaver implements IClassWeaver {
                                        InstructionHandle monitorExitBlockStart = body.insert(element,monitorExitBlock);
                                        
                                        // now move the targeters from the RET to the start of the monitorexit block
-                                       InstructionTargeter[] targeters = element.getTargeters();
+                                       InstructionTargeter[] targeters = element.getTargetersArray();
                                        if (targeters!=null) {
                                                for (int i = 0; i < targeters.length; i++) {
                                        
@@ -1825,7 +1825,7 @@ class BcelClassWeaver implements IClassWeaver {
                                        InstructionHandle monitorExitBlockStart = body.insert(element,monitorExitBlock);
                                        
                                        // now move the targeters from the RET to the start of the monitorexit block
-                                       InstructionTargeter[] targeters = element.getTargeters();
+                                       InstructionTargeter[] targeters = element.getTargetersArray();
                                        if (targeters!=null) {
                                                for (int i = 0; i < targeters.length; i++) {
                                        
@@ -1990,55 +1990,54 @@ class BcelClassWeaver implements IClassWeaver {
                        }                       
                        
                        //copy over tags and range attributes
-               InstructionTargeter[] srcTargeters = src.getTargeters();
-               if (srcTargeters != null) { 
-                   for (int j = srcTargeters.length - 1; j >= 0; j--) {
-                       InstructionTargeter old = srcTargeters[j];
-                       if (old instanceof Tag) {
-                               Tag oldTag = (Tag) old;
-                               Tag fresh = (Tag) tagMap.get(oldTag);
-                               if (fresh == null) {
-                                       fresh = oldTag.copy();
-                                       tagMap.put(oldTag, fresh);
-                               }
-                               dest.addTargeter(fresh);
-                       } else if (old instanceof ExceptionRange) {
-                               ExceptionRange er = (ExceptionRange) old;
-                               if (er.getStart() == src) {
-                                       ExceptionRange freshEr =
-                                               new ExceptionRange(
-                                                       recipient.getBody(),
-                                                       er.getCatchType(),
-                                                       er.getPriority());
-                                       freshEr.associateWithTargets(
-                                                               dest,
-                                                               (InstructionHandle)srcToDest.get(er.getEnd()),
-                                                               (InstructionHandle)srcToDest.get(er.getHandler()));
-                               }
-                                       } else if (old instanceof ShadowRange) {
-                                               ShadowRange oldRange = (ShadowRange) old;
-                                               if (oldRange.getStart() == src) {
-                                                       BcelShadow oldShadow = oldRange.getShadow();
-                                                       BcelShadow freshEnclosing =
-                                                               oldShadow.getEnclosingShadow() == null
-                                                                       ? null
-                                                                       : (BcelShadow) shadowMap.get(oldShadow.getEnclosingShadow());
-                                                       BcelShadow freshShadow =
-                                                               oldShadow.copyInto(recipient, freshEnclosing);
-                                                       ShadowRange freshRange = new ShadowRange(recipient.getBody());
-                                                       freshRange.associateWithShadow(freshShadow);
-                                                       freshRange.associateWithTargets(
-                                                               dest,
-                                                               (InstructionHandle) srcToDest.get(oldRange.getEnd()));
-                                                       shadowMap.put(oldRange, freshRange);
-                                                       //recipient.matchedShadows.add(freshShadow);
-                                                       // XXX should go through the NEW copied shadow and update
-                                                       // the thisVar, targetVar, and argsVar
-                                                       // ??? Might want to also go through at this time and add
-                                                       // "extra" vars to the shadow. 
-                                               }
+                       
+                       Iterator tIter = src.getTargeters().iterator();
+                       while (tIter.hasNext()) {
+                InstructionTargeter old = (InstructionTargeter)tIter.next();
+                if (old instanceof Tag) {
+                       Tag oldTag = (Tag) old;
+                       Tag fresh = (Tag) tagMap.get(oldTag);
+                       if (fresh == null) {
+                               fresh = oldTag.copy();
+                               tagMap.put(oldTag, fresh);
+                       }
+                       dest.addTargeter(fresh);
+                } else if (old instanceof ExceptionRange) {
+                       ExceptionRange er = (ExceptionRange) old;
+                       if (er.getStart() == src) {
+                               ExceptionRange freshEr =
+                                       new ExceptionRange(
+                                               recipient.getBody(),
+                                               er.getCatchType(),
+                                               er.getPriority());
+                               freshEr.associateWithTargets(
+                                                       dest,
+                                                       (InstructionHandle)srcToDest.get(er.getEnd()),
+                                                       (InstructionHandle)srcToDest.get(er.getHandler()));
+                       }
+                               } else if (old instanceof ShadowRange) {
+                                       ShadowRange oldRange = (ShadowRange) old;
+                                       if (oldRange.getStart() == src) {
+                                               BcelShadow oldShadow = oldRange.getShadow();
+                                               BcelShadow freshEnclosing =
+                                                       oldShadow.getEnclosingShadow() == null
+                                                               ? null
+                                                               : (BcelShadow) shadowMap.get(oldShadow.getEnclosingShadow());
+                                               BcelShadow freshShadow =
+                                                       oldShadow.copyInto(recipient, freshEnclosing);
+                                               ShadowRange freshRange = new ShadowRange(recipient.getBody());
+                                               freshRange.associateWithShadow(freshShadow);
+                                               freshRange.associateWithTargets(
+                                                       dest,
+                                                       (InstructionHandle) srcToDest.get(oldRange.getEnd()));
+                                               shadowMap.put(oldRange, freshRange);
+                                               //recipient.matchedShadows.add(freshShadow);
+                                               // XXX should go through the NEW copied shadow and update
+                                               // the thisVar, targetVar, and argsVar
+                                               // ??? Might want to also go through at this time and add
+                                               // "extra" vars to the shadow. 
                                        }
-                   }
+                               }                   
                }                       
                }
                if (!keepReturns) ret.append(footer);
@@ -2126,10 +2125,10 @@ class BcelClassWeaver implements IClassWeaver {
                                }                       
                                
                                //copy over tags and range attributes
-                       InstructionTargeter[] srcTargeters = src.getTargeters();
-                       if (srcTargeters != null) { 
-                           for (int j = srcTargeters.length - 1; j >= 0; j--) {
-                               InstructionTargeter old = srcTargeters[j];
+                       Iterator tIter = src.getTargeters().iterator();
+
+                       while (tIter.hasNext()) {
+                                       InstructionTargeter old = (InstructionTargeter)tIter.next();
                                if (old instanceof Tag) {
                                         Tag oldTag = (Tag) old;
                                         Tag fresh = (Tag) tagMap.get(oldTag);
@@ -2172,7 +2171,6 @@ class BcelClassWeaver implements IClassWeaver {
                                                                // "extra" vars to the shadow. 
                                                        }
                                                }*/
-                           }
                        }                       
                        }
                        if (!keepReturns) newList.append(footer);
@@ -2469,7 +2467,7 @@ class BcelClassWeaver implements IClassWeaver {
         
         // Exception handlers (pr230817)
         if (canMatch(Shadow.ExceptionHandler) && !Range.isRangeHandle(ih)) {
-            InstructionTargeter[] targeters = ih.getTargeters();
+            InstructionTargeter[] targeters = ih.getTargetersArray();
             if (targeters != null) {
                 for (int j = 0; j < targeters.length; j++) {
                     InstructionTargeter t = targeters[j];
index 8bef3fa0ae8392fc55fd6a6f96b3ddbcb7ade5e1..26fbf056675a866ad25046aaa4c378bf86283e87 100644 (file)
@@ -257,7 +257,7 @@ public class BcelShadow extends Shadow {
                }
        }
        private void retargetFrom(InstructionHandle old, InstructionHandle fresh) {
-               InstructionTargeter[] sources = old.getTargeters();
+               InstructionTargeter[] sources = old.getTargetersArray();
                if (sources != null) {
                        for (int i = sources.length - 1; i >= 0; i--) {
                                if (sources[i] instanceof ExceptionRange) {
@@ -317,7 +317,7 @@ public class BcelShadow extends Shadow {
             // Now the exception range starts just after our new instruction.
             // The next bit of code changes the exception range to point at
             // the store instruction
-                       InstructionTargeter[] targeters = start.getTargeters();
+                       InstructionTargeter[] targeters = start.getTargetersArray();
                        for (int i = 0; i < targeters.length; i++) {
                                InstructionTargeter t = targeters[i];
                                if (t instanceof ExceptionRange) {
@@ -577,18 +577,16 @@ public class BcelShadow extends Shadow {
                {
                        int slot = startOfHandler.getInstruction().getIndex();
                        //System.out.println("got store: " + startOfHandler.getInstruction() + ", " + index);
-                       InstructionTargeter[] targeters = startOfHandler.getNext().getTargeters();
-                       if (targeters!=null) {
-                               for (int i=targeters.length-1; i >= 0; i--) {
-                                       if (targeters[i] instanceof LocalVariableTag) {
-                                               LocalVariableTag t = (LocalVariableTag)targeters[i];
-                                               if (t.getSlot() == slot) {
-                                                       return t.getName();
-                                               }
-                                               //System.out.println("tag: " + targeters[i]);
+                       Iterator tIter = startOfHandler.getNext().getTargeters().iterator();
+                       while (tIter.hasNext()) {
+                               InstructionTargeter targeter = (InstructionTargeter)tIter.next();
+                               if (targeter instanceof LocalVariableTag) {
+                                       LocalVariableTag t = (LocalVariableTag)targeter;
+                                       if (t.getSlot() == slot) {
+                                               return t.getName();
                                        }
                                }
-                       }
+                       }
                }
                
                return "<missing>";
@@ -989,7 +987,7 @@ public class BcelShadow extends Shadow {
     }    
 
        public static void retargetAllBranches(InstructionHandle from, InstructionHandle to) {
-               InstructionTargeter[] sources = from.getTargeters();
+               InstructionTargeter[] sources = from.getTargetersArray();
                if (sources != null) {
                        for (int i = sources.length - 1; i >= 0; i--) {
                                InstructionTargeter source = sources[i];
@@ -2644,8 +2642,17 @@ public class BcelShadow extends Shadow {
 //        }
 //    }
 
+       
     /**
-     * ATAJ Handle the inlining for @AJ aspects
+     * Annotation style handling for inlining.
+     * 
+     * Note:
+     * The proceedingjoinpoint is already on the stack (since the user was calling pjp.proceed(...)
+     * 
+     * The proceed map is ignored (in terms of argument repositioning) since we have a fixed expected
+     * format for annotation style.  The aim here is to change the proceed() call into a call to
+     * the xxx_aroundBody0 method.
+     * 
      *
      */
     private InstructionList getRedoneProceedCallForAnnotationStyle(
@@ -2655,25 +2662,7 @@ public class BcelShadow extends Shadow {
         LazyMethodGen localAdviceMethod,
         List argVarList,
         boolean isProceedWithArgs)
-    {
-        // Notes:
-        // proceedingjp is on stack (since user was calling pjp.proceed(...)
-
-        // new Object[]{new Integer(argAdvice1-1)};// arg of proceed
-        // call to proceed(..) is NOT made
-        // instead we do
-        // itar callback args i
-        //     get from array i, convert it to the callback arg i
-        //     if ask for JP, push the one we got on the stack
-        // invoke callback, create conversion back to Object/Integer
-
-        // rest of method -- (hence all those conversions)
-        // intValue() from original code
-        // int res = .. from original code
-
-        //Note: we just don't care about the proceed map etc
-       // (we would need to care if we allow repositioning of arguments in advice signature)
-
+    { 
         InstructionList ret = new InstructionList();
 
         // store the Object[] array on stack if proceed with args
@@ -2681,98 +2670,81 @@ public class BcelShadow extends Shadow {
                
                // STORE the Object[] into a local variable
             Type objectArrayType = Type.OBJECT_ARRAY;
-            int localProceedArgArray = localAdviceMethod.allocateLocal(objectArrayType);
-            ret.append(InstructionFactory.createStore(objectArrayType, localProceedArgArray));
+            int theObjectArrayLocalNumber = localAdviceMethod.allocateLocal(objectArrayType);
+            ret.append(InstructionFactory.createStore(objectArrayType, theObjectArrayLocalNumber));
 
             // STORE the ProceedingJoinPoint instance into a local variable
             Type proceedingJpType = Type.getType("Lorg/aspectj/lang/ProceedingJoinPoint;");
-            int localJp = localAdviceMethod.allocateLocal(proceedingJpType);
-            ret.append(InstructionFactory.createStore(proceedingJpType, localJp));
-
-            // push on stack each element of the object array
-            // that is assumed to be consistent with the callback argument (ie munger args)
-            // TODO do we want to try catch ClassCast and AOOBE exception ?
-
-            // special logic when withincode is static or not
+            int pjpLocalNumber = localAdviceMethod.allocateLocal(proceedingJpType);
+            ret.append(InstructionFactory.createStore(proceedingJpType, pjpLocalNumber));
             
-            // This next bit of code probably makes more sense if you read its implementation for
-            // weaveAroundClosure() - see JoinPointImpl.proceed(Object[]).  Basically depending
-            // on whether the join point has a this/target and whether the pointcut binds this/target
-            // then the arguments to the 'new' proceed call need to be reorganized. (pr126167)
-               boolean relatedPointcutBindsThis = bindsThis(munger);
-               boolean relatedPointcutBindsTarget = bindsTarget(munger);
+            // Aim here initially is to determine whether the user will have provided a new
+            // this/target in the object array and consume them if they have, leaving us the rest of 
+            // the arguments to process as regular arguments to the invocation at the original join point
+            
+               boolean pointcutBindsThis = bindsThis(munger);
+               boolean pointcutBindsTarget = bindsTarget(munger);
                boolean targetIsSameAsThis = getKind().isTargetSameAsThis();
                
-               // two numbers can differ because a pointcut may bind both this/target and yet at the
-               // join point this and target are the same (eg. call)
-            int indexIntoCallbackMethodForArguments = 0;
-            
+            int nextArgumentToProvideForCallback = 0;
             
             if (hasThis() ) {
-                       if (!(relatedPointcutBindsTarget && targetIsSameAsThis)) {
-                       if (relatedPointcutBindsThis) {
-       //                      if (!(relatedPointcutBindsTarget && targetIsSameAsThis)) {
-                                       // they have supplied new this as first entry in object array
-                                        ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray));
+                       if (!(pointcutBindsTarget && targetIsSameAsThis)) {
+                       if (pointcutBindsThis) {
+                                       // they have supplied new this as first entry in object array, consume it
+                                        ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber));
                                     ret.append(Utility.createConstant(fact, 0));
                                     ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
                                     ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[0]));
-                                    indexIntoCallbackMethodForArguments++;
-       //                       }
                        } else {
-                               // use local variable 0 (which is 'this' for a non-static method)
+                               // use local variable 0
                                ret.append(InstructionFactory.createALOAD(0));
-                               indexIntoCallbackMethodForArguments++;
                        }
+                    nextArgumentToProvideForCallback++;
                        }
             }
             
             
             
             if (hasTarget()) {
-               if (relatedPointcutBindsTarget) {
+               if (pointcutBindsTarget) {
                        if (getKind().isTargetSameAsThis()) {
-                                ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray));
-                         ret.append(Utility.createConstant(fact, relatedPointcutBindsThis?1:0));
+                                ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber));
+                         ret.append(Utility.createConstant(fact, pointcutBindsThis?1:0));
                          ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
                          ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[0]));
-                         indexIntoCallbackMethodForArguments++;
                        } else {
-                                int position =(hasThis()&& relatedPointcutBindsThis?1:0);
-                                        ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray));
+                                int position =(hasThis()&& pointcutBindsThis?1:0);
+                                        ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber));
                             ret.append(Utility.createConstant(fact, position));
                             ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
                             ret.append(Utility.createConversion(fact,Type.OBJECT,callbackMethod.getArgumentTypes()[position]));
-                                indexIntoCallbackMethodForArguments++;
                        }
+                    nextArgumentToProvideForCallback++;
                } else {
                        if (getKind().isTargetSameAsThis()) {
                                //ret.append(new ALOAD(0));
                        } else {
                                ret.append(InstructionFactory.createLoad(localAdviceMethod.getArgumentTypes()[0],hasThis()?1:0));
-                               indexIntoCallbackMethodForArguments++;
+                               nextArgumentToProvideForCallback++;
                        }
                }
             }
             
             // Where to start in the object array in order to pick up arguments
-            int indexIntoObjectArrayForArguments = (relatedPointcutBindsThis?1:0)+(relatedPointcutBindsTarget?1:0);
+            int indexIntoObjectArrayForArguments = (pointcutBindsThis?1:0)+(pointcutBindsTarget?1:0);
             
-            
-            for (int i = indexIntoCallbackMethodForArguments, len=callbackMethod.getArgumentTypes().length; i < len; i++) {
+            int len = callbackMethod.getArgumentTypes().length;
+            for (int i = nextArgumentToProvideForCallback; i < len; i++) {
                 Type stateType = callbackMethod.getArgumentTypes()[i];
                 BcelWorld.fromBcel(stateType).resolve(world);
                 if ("Lorg/aspectj/lang/JoinPoint;".equals(stateType.getSignature())) {
-                    ret.append(new InstructionLV(Constants.ALOAD,localJp));// from localAdvice signature
+                    ret.append(new InstructionLV(Constants.ALOAD, pjpLocalNumber));
                 } else {
-                    ret.append(InstructionFactory.createLoad(objectArrayType, localProceedArgArray));
-                    ret.append(Utility.createConstant(fact, i-indexIntoCallbackMethodForArguments +indexIntoObjectArrayForArguments));
+                    ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber));
+                    ret.append(Utility.createConstant(fact, i-nextArgumentToProvideForCallback+indexIntoObjectArrayForArguments));
                     ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
-                    ret.append(Utility.createConversion(
-                            fact,
-                            Type.OBJECT,
-                            stateType
-                    ));
+                    ret.append(Utility.createConversion(fact, Type.OBJECT, stateType));
                 }
             }
 
index 715053f8478d6e2fd7f6e9f6f3406536f9988e2a..ac96c39a8b6c812e2939e1bd62915df235b08ab1 100644 (file)
@@ -400,15 +400,13 @@ public final class LazyMethodGen implements Traceable {
         LineNumberTag lr = null;
         boolean skip = false;
         for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
-            InstructionTargeter[] targeters = ih.getTargeters();
+               Iterator tIter = ih.getTargeters().iterator();
             skip = false;
-            if (targeters != null) {
-                for (int i = targeters.length - 1; i >= 0; i--) {
-                    InstructionTargeter targeter = targeters[i];
-                    if (targeter instanceof LineNumberTag) {
-                        lr = (LineNumberTag) targeter;
-                        skip=true;
-                    }
+               while (tIter.hasNext()) {
+                InstructionTargeter targeter = (InstructionTargeter)tIter.next();
+                if (targeter instanceof LineNumberTag) {
+                    lr = (LineNumberTag) targeter;
+                    skip=true;
                 }
             }
             if (lr != null && !skip) {
@@ -584,10 +582,9 @@ public final class LazyMethodGen implements Traceable {
 //            boolean hasPendingTargeters = false;
             int lcounter = 0;
             for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
-                InstructionTargeter[] targeters = ih.getTargeters();
-                if (targeters != null) {
-                    for (int i = targeters.length - 1; i >= 0; i--) {
-                        InstructionTargeter t = targeters[i];
+               Iterator tIter = ih.getTargeters().iterator();
+               while (tIter.hasNext()) {               
+                        InstructionTargeter t = (InstructionTargeter)tIter.next();//targeters[i];
                         if (t instanceof ExceptionRange) {
                             // assert isRangeHandle(h);
                             ExceptionRange r = (ExceptionRange) t;
@@ -601,7 +598,6 @@ public final class LazyMethodGen implements Traceable {
                         } else {
                             // assert isRangeHandle(h)
                         }
-                    }
                 }
                 if (pendingLabel != null) {
                     labelMap.put(ih, pendingLabel);
@@ -758,10 +754,9 @@ public final class LazyMethodGen implements Traceable {
         InstructionHandle ih,
         int index) 
     {
-        InstructionTargeter[] targeters = ih.getTargeters();
-        if (targeters == null) return null;
-        for (int i = targeters.length - 1; i >= 0; i--) {
-            InstructionTargeter t = targeters[i];
+       Iterator tIter = ih.getTargeters().iterator();
+       while (tIter.hasNext()) {
+            InstructionTargeter t = (InstructionTargeter)tIter.next();
             if (t instanceof LocalVariableTag) {
                 LocalVariableTag lvt = (LocalVariableTag) t;
                 if (lvt.getSlot() == index) return lvt;
@@ -774,10 +769,9 @@ public final class LazyMethodGen implements Traceable {
         InstructionHandle ih,
         int prevLine) 
     {
-        InstructionTargeter[] targeters = ih.getTargeters();
-        if (targeters == null) return prevLine;
-        for (int i = targeters.length - 1; i >= 0; i--) {
-            InstructionTargeter t = targeters[i];
+       Iterator tIter = ih.getTargeters().iterator();
+       while (tIter.hasNext()) {
+            InstructionTargeter t = (InstructionTargeter)tIter.next();
             if (t instanceof LineNumberTag) {
                 return ((LineNumberTag)t).getLineNumber();
             }
@@ -1021,10 +1015,9 @@ public final class LazyMethodGen implements Traceable {
                 
                 // now deal with line numbers 
                 // and store up info for local variables
-                InstructionTargeter[] targeters = oldInstructionHandle.getTargeters();
-                if (targeters != null) {
-                    for (int k = targeters.length - 1; k >= 0; k--) {
-                        InstructionTargeter targeter = targeters[k];
+                       Iterator tIter = oldInstructionHandle.getTargeters().iterator();
+                       while (tIter.hasNext()) {
+                        InstructionTargeter targeter = (InstructionTargeter)tIter.next();//targeters[k];
                         if (targeter instanceof LineNumberTag) {
                             int line = ((LineNumberTag)targeter).getLineNumber();
                             if (line != currLine) {
@@ -1044,7 +1037,6 @@ public final class LazyMethodGen implements Traceable {
                                p.end = newInstructionHandle;
                             }
                         }
-                    }
                 }
                 
                 // now continue
@@ -1101,11 +1093,13 @@ public final class LazyMethodGen implements Traceable {
                        if (inst instanceof InstructionBranch) {
                                branchInstructions.add(iHandle);
                        }
-
-              InstructionTargeter[] targeters = iHandle.getTargeters();
-              if (targeters != null) {
-                  for (int k = targeters.length - 1; k >= 0; k--) {
-                      InstructionTargeter targeter = targeters[k];
+                       Iterator tIter = iHandle.getTargeters().iterator();
+                       while (tIter.hasNext()) {
+                               
+//              InstructionTargeter[] targeters = iHandle.getTargetersArray();
+//              if (targeters != null) {
+//                  for (int k = targeters.length - 1; k >= 0; k--) {
+                      InstructionTargeter targeter = (InstructionTargeter)tIter.next();//targeters[k];
                       if (targeter instanceof LineNumberTag) {
                           int line = ((LineNumberTag)targeter).getLineNumber();
                           if (line != currLine) {
@@ -1118,13 +1112,13 @@ public final class LazyMethodGen implements Traceable {
                           // If we don't know about it, create a new position and store
                           // If we do know about it - update its end position
                           if (p==null) {
-                               LVPosition newp = new LVPosition();
-                               newp.start=newp.end=iHandle;
-                               localVariables.put(lvt,newp);
+                                 LVPosition newp = new LVPosition();
+                                 newp.start=newp.end=iHandle;
+                                 localVariables.put(lvt,newp);
                           } else {
-                               p.end = iHandle;
+                                 p.end = iHandle;
                           }
-                      }
+//                      }
                   }
               }
                }
@@ -1461,11 +1455,9 @@ public final class LazyMethodGen implements Traceable {
                
                for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
                        assertGoodHandle(ih, body, ranges, from);
-                       InstructionTargeter[] ts = ih.getTargeters();
-                       if (ts != null) {
-                               for (int i = ts.length - 1; i >= 0; i--) {
-                                       assertGoodTargeter(ts[i], ih, body, from);
-                               }
+                       Iterator tIter = ih.getTargeters().iterator();
+                       while (tIter.hasNext()) {
+                               assertGoodTargeter((InstructionTargeter)tIter.next(),ih,body,from);
                        }
                }
        }
@@ -1547,10 +1539,9 @@ public final class LazyMethodGen implements Traceable {
         InstructionTargeter targeter,
         String from) 
     {
-       InstructionTargeter[] ts = target.getTargeters();
-       if (ts == null) throw new BCException("bad targeting relationship in " + from);
-       for (int i = ts.length - 1; i >= 0; i--) {
-               if (ts[i] == targeter) return;
+       Iterator tIter = target.getTargeters().iterator();
+       while (tIter.hasNext()) {
+               if (((InstructionTargeter)tIter.next()) == targeter) return;
        }
                throw new RuntimeException("bad targeting relationship in " + from);
     }
@@ -1580,12 +1571,15 @@ public final class LazyMethodGen implements Traceable {
 
     private static Range getRangeAndAssertExactlyOne(InstructionHandle ih, String from) {
        Range ret = null;
-       InstructionTargeter[] ts = ih.getTargeters();
-       if (ts == null) throw new BCException("range handle with no range in " + from);
-       for (int i = ts.length - 1; i >= 0; i--) {
-               if (ts[i] instanceof Range) {
+       Iterator tIter = ih.getTargeters().iterator();
+       if (!tIter.hasNext()) {
+               throw new BCException("range handle with no range in " + from);
+       }
+       while (tIter.hasNext()) {
+               InstructionTargeter ts = (InstructionTargeter)tIter.next();
+               if (ts instanceof Range) {
                        if (ret != null) throw new BCException("range handle with multiple ranges in " + from);
-                       ret = (Range) ts[i];
+                       ret = (Range) ts;
                }
        }
        if (ret == null) throw new BCException("range handle with no range in " + from);