~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import java.util.HashMap;
20
20
import java.util.HashSet;
21
21
import java.util.Iterator;
 
22
import java.util.LinkedHashSet;
22
23
import java.util.List;
23
24
import java.util.Map;
24
25
import java.util.Properties;
93
94
        private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelClassWeaver.class);
94
95
 
95
96
        public static boolean weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
96
 
                        List<ConcreteTypeMunger> typeMungers, List lateTypeMungers, boolean inReweavableMode) {
 
97
                        List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode) {
97
98
                BcelClassWeaver classWeaver = new BcelClassWeaver(world, clazz, shadowMungers, typeMungers, lateTypeMungers);
98
99
                classWeaver.setReweavableMode(inReweavableMode);
99
100
                boolean b = classWeaver.weave();
105
106
        private final LazyClassGen clazz;
106
107
        private final List<ShadowMunger> shadowMungers;
107
108
        private final List<ConcreteTypeMunger> typeMungers;
108
 
        private final List lateTypeMungers;
 
109
        private final List<ConcreteTypeMunger> lateTypeMungers;
109
110
 
110
111
        private List<ShadowMunger>[] indexedShadowMungers;
111
112
        private boolean canMatchBodyShadows = false;
136
137
        private final List<BcelShadow> initializationShadows = new ArrayList<BcelShadow>();
137
138
 
138
139
        private BcelClassWeaver(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
139
 
                        List<ConcreteTypeMunger> typeMungers, List lateTypeMungers) {
 
140
                        List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers) {
140
141
                super();
141
142
                this.world = world;
142
143
                this.clazz = clazz;
286
287
                        return;
287
288
                }
288
289
 
289
 
                for (Iterator i = addedLazyMethodGens.iterator(); i.hasNext();) {
290
 
                        LazyMethodGen existing = (LazyMethodGen) i.next();
 
290
                for (Iterator<LazyMethodGen> i = addedLazyMethodGens.iterator(); i.hasNext();) {
 
291
                        LazyMethodGen existing = i.next();
291
292
                        if (signaturesMatch(mg, existing)) {
292
293
                                if (existing.definingType == null) {
293
294
                                        // this means existing was introduced on the class itself
334
335
                        mods = mods - Modifier.ABSTRACT;
335
336
                }
336
337
 
337
 
                LazyMethodGen ret = new LazyMethodGen(mods, BcelWorld.makeBcelType(member.getReturnType()), member.getName(), BcelWorld
338
 
                                .makeBcelTypes(member.getParameterTypes()), UnresolvedType.getNames(member.getExceptions()), gen);
 
338
                LazyMethodGen ret = new LazyMethodGen(mods, BcelWorld.makeBcelType(member.getReturnType()), member.getName(),
 
339
                                BcelWorld.makeBcelTypes(member.getParameterTypes()), UnresolvedType.getNames(member.getExceptions()), gen);
339
340
 
340
341
                // 43972 : Static crosscutting makes interfaces unusable for javac
341
342
                // ret.makeSynthetic();
355
356
 
356
357
                if (whatToBridgeTo == null) {
357
358
                        whatToBridgeTo = new ResolvedMemberImpl(Member.METHOD, whatToBridgeToMethodGen.getEnclosingClass().getType(),
358
 
                                        whatToBridgeToMethodGen.getAccessFlags(), whatToBridgeToMethodGen.getName(), whatToBridgeToMethodGen
359
 
                                                        .getSignature());
 
359
                                        whatToBridgeToMethodGen.getAccessFlags(), whatToBridgeToMethodGen.getName(),
 
360
                                        whatToBridgeToMethodGen.getSignature());
360
361
                }
361
362
                // The bridge method in this type will have the same signature as the one in the supertype
362
363
                LazyMethodGen bridgeMethod = makeBridgeMethod(clazz, theBridgeMethod);
401
402
         */
402
403
        public boolean weave() {
403
404
                if (clazz.isWoven() && !clazz.isReweavable()) {
404
 
                        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ALREADY_WOVEN, clazz.getType().getName()), ty
405
 
                                        .getSourceLocation(), null);
 
405
                        world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ALREADY_WOVEN, clazz.getType().getName()),
 
406
                                        ty.getSourceLocation(), null);
406
407
                        return false;
407
408
                }
408
409
 
495
496
                        // infinetly as compiler will have detected and reported
496
497
                        // "Recursive constructor invocation"
497
498
                        while (inlineSelfConstructors(methodGens)) {
498
 
                                ;
499
499
                        }
500
500
                        positionAndImplement(initializationShadows);
501
501
                }
502
502
 
503
503
                // now proceed with late type mungers
504
504
                if (lateTypeMungers != null) {
505
 
                        for (Iterator i = lateTypeMungers.iterator(); i.hasNext();) {
 
505
                        for (Iterator<ConcreteTypeMunger> i = lateTypeMungers.iterator(); i.hasNext();) {
506
506
                                BcelTypeMunger munger = (BcelTypeMunger) i.next();
507
507
                                if (munger.matches(clazz.getType())) {
508
508
                                        boolean typeMungerAffectedType = munger.munge(this);
610
610
                                if (parameterType instanceof UnresolvedTypeVariableReferenceType) {
611
611
                                        parameterType = ((UnresolvedTypeVariableReferenceType) parameterType).getTypeVariable().getFirstBound();
612
612
                                }
613
 
                                UnresolvedType parameterType2 = methodParamsArray[p];
614
613
 
615
614
                                if (b) { // !parameterType.resolve(w).equals(parameterType2.resolve(w))) {
616
615
                                        sameParams = false;
725
724
                        }
726
725
                }
727
726
                // was: List l = typeToCheck.getInterTypeMungers();
728
 
                List l = (typeToCheck.isRawType() ? typeToCheck.getGenericType().getInterTypeMungers() : typeToCheck.getInterTypeMungers());
729
 
                for (Iterator iterator = l.iterator(); iterator.hasNext();) {
730
 
                        Object o = iterator.next();
 
727
                List<ConcreteTypeMunger> l = (typeToCheck.isRawType() ? typeToCheck.getGenericType().getInterTypeMungers() : typeToCheck
 
728
                                .getInterTypeMungers());
 
729
                for (Iterator<ConcreteTypeMunger> iterator = l.iterator(); iterator.hasNext();) {
 
730
                        ConcreteTypeMunger o = iterator.next();
731
731
                        // FIXME asc if its not a BcelTypeMunger then its an
732
732
                        // EclipseTypeMunger ... do I need to worry about that?
733
733
                        if (o instanceof BcelTypeMunger) {
854
854
                                        System.err.println("Bridging:checking superinterface " + interfaces[j]);
855
855
                                }
856
856
                                ResolvedType interfaceType = world.resolve(interfaces[j]);
857
 
                                overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(), clazz
858
 
                                                .getPackageName(), bm);
 
857
                                overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
 
858
                                                clazz.getPackageName(), bm);
859
859
                                if (overriddenMethod != null) {
860
860
                                        String key = new StringBuffer().append(overriddenMethod.getName())
861
861
                                                        .append(overriddenMethod.getSignatureErased()).toString(); // pr
937
937
                                                        annotationsToAdd.add(ag);
938
938
                                                        mg.addAnnotation(decaM.getAnnotation());
939
939
 
940
 
                                                        AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
941
 
                                                                        .getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
 
940
                                                        AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(),
 
941
                                                                        clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
942
942
                                                        reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM, mg.getDeclarationLineNumber());
943
943
                                                        isChanged = true;
944
944
                                                        modificationOccured = true;
979
979
                                                                AnnotationGen ag = new AnnotationGen(a, clazz.getConstantPool(), true);
980
980
                                                                annotationsToAdd.add(ag);
981
981
                                                                mg.addAnnotation(decaM.getAnnotation());
982
 
                                                                AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
983
 
                                                                                .getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
 
982
                                                                AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(),
 
983
                                                                                clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
984
984
                                                                isChanged = true;
985
985
                                                                modificationOccured = true;
986
986
                                                                forRemoval.add(decaM);
1047
1047
                                }
1048
1048
                        }
1049
1049
                        getWorld().getMessageHandler().handleMessage(
1050
 
                                        WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] { sig.toString(),
1051
 
                                                        loc.toString(), decaM.getAnnotationString(),
1052
 
                                                        methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
1053
 
                                                        Utility.beautifyLocation(decaM.getSourceLocation()) }));
 
1050
                                        WeaveMessage.constructWeavingMessage(
 
1051
                                                        WeaveMessage.WEAVEMESSAGE_ANNOTATES,
 
1052
                                                        new String[] { sig.toString(), loc.toString(), decaM.getAnnotationString(),
 
1053
                                                                        methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
 
1054
                                                                        Utility.beautifyLocation(decaM.getSourceLocation()) }));
1054
1055
                }
1055
1056
        }
1056
1057
 
1121
1122
         * will iterate over the fields repeatedly until everything has been applied.
1122
1123
         * 
1123
1124
         */
1124
 
        private boolean weaveAtFieldRepeatedly(List<DeclareAnnotation> decaFs, List itdFields, List<Integer> reportedErrors) {
 
1125
        private boolean weaveAtFieldRepeatedly(List<DeclareAnnotation> decaFs, List<ConcreteTypeMunger> itdFields,
 
1126
                        List<Integer> reportedErrors) {
1125
1127
                boolean isChanged = false;
1126
 
                for (Iterator iter = itdFields.iterator(); iter.hasNext();) {
 
1128
                for (Iterator<ConcreteTypeMunger> iter = itdFields.iterator(); iter.hasNext();) {
1127
1129
                        BcelTypeMunger fieldMunger = (BcelTypeMunger) iter.next();
1128
1130
                        ResolvedMember itdIsActually = fieldMunger.getSignature();
1129
 
                        List<DeclareAnnotation> worthRetrying = new ArrayList<DeclareAnnotation>();
 
1131
                        Set<DeclareAnnotation> worthRetrying = new LinkedHashSet<DeclareAnnotation>();
1130
1132
                        boolean modificationOccured = false;
1131
1133
 
1132
1134
                        for (Iterator<DeclareAnnotation> iter2 = decaFs.iterator(); iter2.hasNext();) {
1133
1135
                                DeclareAnnotation decaF = iter2.next();
1134
 
 
1135
1136
                                if (decaF.matches(itdIsActually, world)) {
1136
 
                                        LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
1137
 
                                        if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
1138
 
                                                continue; // skip this one...
 
1137
                                        if (decaF.isRemover()) {
 
1138
                                                LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
 
1139
                                                if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
 
1140
                                                        isChanged = true;
 
1141
                                                        // something to remove
 
1142
                                                        annotationHolder.removeAnnotation(decaF.getAnnotationType());
 
1143
                                                        AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
 
1144
                                                                        decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
 
1145
                                                } else {
 
1146
                                                        worthRetrying.add(decaF);
 
1147
                                                }
 
1148
                                        } else {
 
1149
 
 
1150
                                                LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
 
1151
                                                if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
 
1152
                                                        continue; // skip this one...
 
1153
                                                }
 
1154
                                                annotationHolder.addAnnotation(decaF.getAnnotation());
 
1155
                                                AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
 
1156
                                                                decaF.getSourceLocation(), itdIsActually.getSourceLocation(), false);
 
1157
                                                isChanged = true;
 
1158
                                                modificationOccured = true;
1139
1159
                                        }
1140
 
                                        annotationHolder.addAnnotation(decaF.getAnnotation());
1141
 
                                        AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
1142
 
                                                        .getSourceLocation(), itdIsActually.getSourceLocation());
1143
 
                                        isChanged = true;
1144
 
                                        modificationOccured = true;
1145
 
 
1146
1160
                                } else {
1147
1161
                                        if (!decaF.isStarredAnnotationPattern()) {
1148
1162
                                                worthRetrying.add(decaF); // an annotation is specified
1158
1172
                                for (Iterator<DeclareAnnotation> iter2 = worthRetrying.iterator(); iter2.hasNext();) {
1159
1173
                                        DeclareAnnotation decaF = iter2.next();
1160
1174
                                        if (decaF.matches(itdIsActually, world)) {
1161
 
                                                LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
1162
 
                                                if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
1163
 
                                                        continue; // skip this one...
 
1175
                                                if (decaF.isRemover()) {
 
1176
                                                        LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
 
1177
                                                        if (annotationHolder.hasAnnotation(decaF.getAnnotationType())) {
 
1178
                                                                isChanged = true;
 
1179
                                                                // something to remove
 
1180
                                                                annotationHolder.removeAnnotation(decaF.getAnnotationType());
 
1181
                                                                AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
 
1182
                                                                                decaF.getSourceLocation(), itdIsActually.getSourceLocation(), true);
 
1183
                                                                forRemoval.add(decaF);
 
1184
                                                        }
 
1185
                                                } else {
 
1186
                                                        LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
 
1187
                                                        if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors)) {
 
1188
                                                                continue; // skip this one...
 
1189
                                                        }
 
1190
                                                        annotationHolder.addAnnotation(decaF.getAnnotation());
 
1191
                                                        AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
 
1192
                                                                        decaF.getSourceLocation(), itdIsActually.getSourceLocation(), false);
 
1193
                                                        isChanged = true;
 
1194
                                                        modificationOccured = true;
 
1195
                                                        forRemoval.add(decaF);
1164
1196
                                                }
1165
 
                                                annotationHolder.addAnnotation(decaF.getAnnotation());
1166
 
                                                AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
1167
 
                                                                .getSourceLocation(), itdIsActually.getSourceLocation());
1168
 
                                                isChanged = true;
1169
 
                                                modificationOccured = true;
1170
 
                                                forRemoval.add(decaF);
1171
1197
                                        }
1172
1198
                                }
1173
1199
                                worthRetrying.removeAll(forRemoval);
1202
1228
                                        annotationHolder.addAnnotation(decaMC.getAnnotation());
1203
1229
                                        isChanged = true;
1204
1230
                                        AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
1205
 
                                                        unMangledInterMethod.getSourceLocation());
 
1231
                                                        unMangledInterMethod.getSourceLocation(), false);
1206
1232
                                        reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1);
1207
1233
                                        modificationOccured = true;
1208
1234
                                } else {
1226
1252
                                                annotationHolder.addAnnotation(decaMC.getAnnotation());
1227
1253
                                                unMangledInterMethod.addAnnotation(decaMC.getAnnotation());
1228
1254
                                                AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
1229
 
                                                                unMangledInterMethod.getSourceLocation());
 
1255
                                                                unMangledInterMethod.getSourceLocation(), false);
1230
1256
                                                isChanged = true;
1231
1257
                                                modificationOccured = true;
1232
1258
                                                forRemoval.add(decaMC);
1239
1265
        }
1240
1266
 
1241
1267
        private boolean dontAddTwice(DeclareAnnotation decaF, AnnotationAJ[] dontAddMeTwice) {
1242
 
                for (int i = 0; i < dontAddMeTwice.length; i++) {
1243
 
                        AnnotationAJ ann = dontAddMeTwice[i];
 
1268
                for (AnnotationAJ ann : dontAddMeTwice) {
1244
1269
                        if (ann != null && decaF.getAnnotation().getTypeName().equals(ann.getTypeName())) {
1245
 
                                // dontAddMeTwice[i] = null; // incase it really has been added
1246
 
                                // twice!
1247
1270
                                return true;
1248
1271
                        }
1249
1272
                }
1250
1273
                return false;
1251
1274
        }
1252
1275
 
 
1276
        // BUGWARNING not getting enough warnings out on declare @field ? There is a potential problem here with warnings not
 
1277
        // coming out - this will occur if they are created on the second iteration round this loop.
 
1278
        // We currently deactivate error reporting for the second time round. A possible solution is to record what annotations
 
1279
        // were added by what decafs and check that to see if an error needs to be reported - this would be expensive so lets
 
1280
        // skip it for now
1253
1281
        /**
1254
 
         * Weave any declare @field statements into the fields of the supplied class
 
1282
         * Weave any declare @field statements into the fields of the supplied class. This will attempt to apply them to the ITDs too.
1255
1283
         * 
1256
1284
         * Interesting case relating to public ITDd fields. The annotations are really stored against the interfieldinit method in the
1257
1285
         * aspect, but the public field is placed in the target type and then is processed in the 2nd pass over fields that occurs. I
1259
1287
         * as well as on the interfieldinit method.
1260
1288
         */
1261
1289
        private boolean weaveDeclareAtField(LazyClassGen clazz) {
1262
 
 
1263
 
                // BUGWARNING not getting enough warnings out on declare @field ?
1264
 
                // There is a potential problem here with warnings not coming out - this
1265
 
                // will occur if they are created on the second iteration round this
1266
 
                // loop.
1267
 
                // We currently deactivate error reporting for the second time round.
1268
 
                // A possible solution is to record what annotations were added by what
1269
 
                // decafs and check that to see if an error needs to be reported - this
1270
 
                // would be expensive so lets skip it for now
1271
 
 
1272
1290
                List<Integer> reportedProblems = new ArrayList<Integer>();
1273
 
 
1274
1291
                List<DeclareAnnotation> allDecafs = world.getDeclareAnnotationOnFields();
1275
1292
                if (allDecafs.isEmpty()) {
1276
1293
                        return false;
1277
1294
                }
1278
 
 
1279
 
                boolean isChanged = false;
1280
 
                List<ConcreteTypeMunger> itdFields = getITDSubset(clazz, ResolvedTypeMunger.Field);
1281
 
                if (itdFields != null) {
1282
 
                        isChanged = weaveAtFieldRepeatedly(allDecafs, itdFields, reportedProblems);
1283
 
                }
1284
 
 
1285
 
                List<DeclareAnnotation> decaFs = getMatchingSubset(allDecafs, clazz.getType());
1286
 
                if (decaFs.isEmpty()) {
1287
 
                        return false; // nothing more to do
1288
 
                }
 
1295
                boolean typeIsChanged = false;
 
1296
                List<ConcreteTypeMunger> relevantItdFields = getITDSubset(clazz, ResolvedTypeMunger.Field);
 
1297
                if (relevantItdFields != null) {
 
1298
                        typeIsChanged = weaveAtFieldRepeatedly(allDecafs, relevantItdFields, reportedProblems);
 
1299
                }
 
1300
 
 
1301
                List<DeclareAnnotation> decafs = getMatchingSubset(allDecafs, clazz.getType());
 
1302
                if (decafs.isEmpty()) {
 
1303
                        return typeIsChanged;
 
1304
                }
 
1305
 
1289
1306
                List<BcelField> fields = clazz.getFieldGens();
1290
1307
                if (fields != null) {
1291
1308
                        Set<DeclareAnnotation> unusedDecafs = new HashSet<DeclareAnnotation>();
1292
 
                        unusedDecafs.addAll(decaFs);
1293
 
                        for (int fieldCounter = 0; fieldCounter < fields.size(); fieldCounter++) {
1294
 
                                BcelField aBcelField = fields.get(fieldCounter);// new
1295
 
                                // BcelField(clazz.getBcelObjectType(),fields[fieldCounter
1296
 
                                // ]);
1297
 
                                if (!aBcelField.getName().startsWith(NameMangler.PREFIX)) {
 
1309
                        unusedDecafs.addAll(decafs);
 
1310
                        for (BcelField field : fields) {
 
1311
                                if (!field.getName().startsWith(NameMangler.PREFIX)) {
1298
1312
                                        // Single first pass
1299
 
                                        List<DeclareAnnotation> worthRetrying = new ArrayList<DeclareAnnotation>();
 
1313
                                        Set<DeclareAnnotation> worthRetrying = new LinkedHashSet<DeclareAnnotation>();
1300
1314
                                        boolean modificationOccured = false;
1301
 
 
1302
 
                                        AnnotationAJ[] dontAddMeTwice = aBcelField.getAnnotations();
 
1315
                                        AnnotationAJ[] dontAddMeTwice = field.getAnnotations();
1303
1316
 
1304
1317
                                        // go through all the declare @field statements
1305
 
                                        for (DeclareAnnotation decaF : decaFs) {
1306
 
                                                if (decaF.getAnnotation() == null) {
 
1318
                                        for (DeclareAnnotation decaf : decafs) {
 
1319
                                                if (decaf.getAnnotation() == null) {
1307
1320
                                                        return false;
1308
1321
                                                }
1309
 
                                                if (decaF.matches(aBcelField, world)) {
1310
 
 
1311
 
                                                        if (!dontAddTwice(decaF, dontAddMeTwice)) {
1312
 
                                                                if (doesAlreadyHaveAnnotation(aBcelField, decaF, reportedProblems)) {
1313
 
                                                                        // remove the declare @field since don't
1314
 
                                                                        // want an error when
1315
 
                                                                        // the annotation is already there
1316
 
                                                                        unusedDecafs.remove(decaF);
1317
 
                                                                        continue;
1318
 
                                                                }
1319
 
 
1320
 
                                                                if (decaF.getAnnotation().isRuntimeVisible()) { // isAnnotationWithRuntimeRetention
1321
 
                                                                        // (
1322
 
                                                                        // clazz
1323
 
                                                                        // .
1324
 
                                                                        // getJavaClass(world))){
1325
 
                                                                        // if(decaF.getAnnotationTypeX().
1326
 
                                                                        // isAnnotationWithRuntimeRetention(world)){
1327
 
                                                                        // it should be runtime visible, so put it
1328
 
                                                                        // on the Field
1329
 
                                                                        // Annotation a =
1330
 
                                                                        // decaF.getAnnotationX().getBcelAnnotation
1331
 
                                                                        // ();
1332
 
                                                                        // AnnotationGen ag = new
1333
 
                                                                        // AnnotationGen(a,clazz
1334
 
                                                                        // .getConstantPoolGen(),true);
1335
 
                                                                        // FieldGen myGen = new
1336
 
                                                                        // FieldGen(fields[fieldCounter
1337
 
                                                                        // ],clazz.getConstantPoolGen());
1338
 
                                                                        // myGen.addAnnotation(ag);
1339
 
                                                                        // Field newField = myGen.getField();
1340
 
 
1341
 
                                                                        aBcelField.addAnnotation(decaF.getAnnotation());
1342
 
                                                                        // clazz.replaceField(fields[fieldCounter],
1343
 
                                                                        // newField);
1344
 
                                                                        // fields[fieldCounter]=newField;
1345
 
 
 
1322
                                                if (decaf.matches(field, world)) {
 
1323
                                                        if (decaf.isRemover()) {
 
1324
                                                                AnnotationAJ annotation = decaf.getAnnotation();
 
1325
                                                                if (field.hasAnnotation(annotation.getType())) {
 
1326
                                                                        // something to remove
 
1327
                                                                        typeIsChanged = true;
 
1328
                                                                        field.removeAnnotation(annotation);
 
1329
                                                                        AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
 
1330
                                                                                        decaf.getSourceLocation(), clazz.getName(), field, true);
 
1331
                                                                        reportFieldAnnotationWeavingMessage(clazz, field, decaf, true);
1346
1332
                                                                } else {
1347
 
                                                                        aBcelField.addAnnotation(decaF.getAnnotation());
1348
 
                                                                }
1349
 
                                                        }
1350
 
 
1351
 
                                                        AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(), decaF
1352
 
                                                                        .getSourceLocation(), clazz.getName(), aBcelField);
1353
 
                                                        reportFieldAnnotationWeavingMessage(clazz, fields, fieldCounter, decaF);
1354
 
                                                        isChanged = true;
1355
 
                                                        modificationOccured = true;
1356
 
                                                        // remove the declare @field since have matched
1357
 
                                                        // against it
1358
 
                                                        unusedDecafs.remove(decaF);
1359
 
                                                } else {
1360
 
                                                        if (!decaF.isStarredAnnotationPattern()) {
1361
 
                                                                worthRetrying.add(decaF); // an annotation is
1362
 
                                                                // specified that
1363
 
                                                                // might be put on
1364
 
                                                                // by a subsequent
1365
 
                                                                // decaf
1366
 
                                                        }
 
1333
                                                                        worthRetrying.add(decaf);
 
1334
                                                                }
 
1335
                                                                unusedDecafs.remove(decaf);
 
1336
                                                        } else {
 
1337
                                                                if (!dontAddTwice(decaf, dontAddMeTwice)) {
 
1338
                                                                        if (doesAlreadyHaveAnnotation(field, decaf, reportedProblems)) {
 
1339
                                                                                // remove the declare @field since don't want an error when the annotation is already there
 
1340
                                                                                unusedDecafs.remove(decaf);
 
1341
                                                                                continue;
 
1342
                                                                        }
 
1343
                                                                        field.addAnnotation(decaf.getAnnotation());
 
1344
                                                                }
 
1345
                                                                AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
 
1346
                                                                                decaf.getSourceLocation(), clazz.getName(), field, false);
 
1347
                                                                reportFieldAnnotationWeavingMessage(clazz, field, decaf, false);
 
1348
                                                                typeIsChanged = true;
 
1349
                                                                modificationOccured = true;
 
1350
                                                                unusedDecafs.remove(decaf);
 
1351
                                                        }
 
1352
                                                } else if (!decaf.isStarredAnnotationPattern() || decaf.isRemover()) {
 
1353
                                                        worthRetrying.add(decaf); // an annotation is specified that might be put on by a subsequent decaf
1367
1354
                                                }
1368
1355
                                        }
1369
1356
 
1370
1357
                                        // Multiple secondary passes
1371
1358
                                        while (!worthRetrying.isEmpty() && modificationOccured) {
1372
1359
                                                modificationOccured = false;
1373
 
                                                // lets have another go
 
1360
                                                // lets have another go with any remaining ones
1374
1361
                                                List<DeclareAnnotation> forRemoval = new ArrayList<DeclareAnnotation>();
1375
1362
                                                for (Iterator<DeclareAnnotation> iter = worthRetrying.iterator(); iter.hasNext();) {
1376
1363
                                                        DeclareAnnotation decaF = iter.next();
1377
 
                                                        if (decaF.matches(aBcelField, world)) {
1378
 
                                                                // below code is for recursive things
1379
 
                                                                if (doesAlreadyHaveAnnotation(aBcelField, decaF, reportedProblems)) {
1380
 
                                                                        // remove the declare @field since don't
1381
 
                                                                        // want an error when
1382
 
                                                                        // the annotation is already there
 
1364
 
 
1365
                                                        if (decaF.matches(field, world)) {
 
1366
                                                                if (decaF.isRemover()) {
 
1367
                                                                        AnnotationAJ annotation = decaF.getAnnotation();
 
1368
                                                                        if (field.hasAnnotation(annotation.getType())) {
 
1369
                                                                                // something to remove
 
1370
                                                                                typeIsChanged = modificationOccured = true;
 
1371
                                                                                forRemoval.add(decaF);
 
1372
                                                                                field.removeAnnotation(annotation);
 
1373
                                                                                AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
 
1374
                                                                                                decaF.getSourceLocation(), clazz.getName(), field, true);
 
1375
                                                                                reportFieldAnnotationWeavingMessage(clazz, field, decaF, true);
 
1376
                                                                        }
 
1377
                                                                } else {
 
1378
                                                                        // below code is for recursive things
1383
1379
                                                                        unusedDecafs.remove(decaF);
1384
 
                                                                        continue; // skip this one...
 
1380
                                                                        if (doesAlreadyHaveAnnotation(field, decaF, reportedProblems)) {
 
1381
                                                                                continue;
 
1382
                                                                        }
 
1383
                                                                        field.addAnnotation(decaF.getAnnotation());
 
1384
                                                                        AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
 
1385
                                                                                        decaF.getSourceLocation(), clazz.getName(), field, false);
 
1386
                                                                        typeIsChanged = modificationOccured = true;
 
1387
                                                                        forRemoval.add(decaF);
1385
1388
                                                                }
1386
 
                                                                aBcelField.addAnnotation(decaF.getAnnotation());
1387
 
                                                                AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(), decaF
1388
 
                                                                                .getSourceLocation(), clazz.getName(), aBcelField);
1389
 
                                                                isChanged = true;
1390
 
                                                                modificationOccured = true;
1391
 
                                                                forRemoval.add(decaF);
1392
 
                                                                // remove the declare @field since have matched
1393
 
                                                                // against it
1394
 
                                                                unusedDecafs.remove(decaF);
1395
1389
                                                        }
1396
1390
                                                }
1397
1391
                                                worthRetrying.removeAll(forRemoval);
1400
1394
                        }
1401
1395
                        checkUnusedDeclareAts(unusedDecafs, true);
1402
1396
                }
1403
 
                return isChanged;
 
1397
                return typeIsChanged;
1404
1398
        }
1405
1399
 
1406
1400
        // bug 99191 - put out an error message if the type doesn't exist
1413
1407
                for (DeclareAnnotation declA : unusedDecaTs) {
1414
1408
 
1415
1409
                        // Error if an exact type pattern was specified
1416
 
                        boolean shouldCheck = declA.isExactPattern() || declA.getSignaturePattern().getExactDeclaringTypes().size() != 0;// !=
1417
 
                                                                                                                                                                                                                                                                // null;//
1418
 
                                                                                                                                                                                                                                                                // instanceof
1419
 
                        // ExactTypePattern;
 
1410
                        boolean shouldCheck = declA.isExactPattern() || declA.getSignaturePattern().getExactDeclaringTypes().size() != 0;
1420
1411
 
1421
1412
                        if (shouldCheck && declA.getKind() != DeclareAnnotation.AT_CONSTRUCTOR) {
1422
 
                                if (declA.getSignaturePattern().isMatchOnAnyName()/* getName().isAny() */) {
 
1413
                                if (declA.getSignaturePattern().isMatchOnAnyName()) {
1423
1414
                                        shouldCheck = false;
1424
1415
                                } else {
1425
1416
                                        List<ExactTypePattern> declaringTypePatterns = declA.getSignaturePattern().getExactDeclaringTypes();
1455
1446
                                if (!itdMatch) {
1456
1447
                                        IMessage message = null;
1457
1448
                                        if (isDeclareAtField) {
1458
 
                                                message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist", declA
1459
 
                                                                .getSourceLocation(), true);
 
1449
                                                message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist",
 
1450
                                                                declA.getSourceLocation(), true);
1460
1451
                                        } else {
1461
 
                                                message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist", declA
1462
 
                                                                .getSourceLocation(), true);
 
1452
                                                message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist",
 
1453
                                                                declA.getSourceLocation(), true);
1463
1454
                                        }
1464
1455
                                        world.getMessageHandler().handleMessage(message);
1465
1456
                                }
1468
1459
        }
1469
1460
 
1470
1461
        // TAG: WeavingMessage
1471
 
        private void reportFieldAnnotationWeavingMessage(LazyClassGen clazz, List fields, int fieldCounter, DeclareAnnotation decaF) {
 
1462
        private void reportFieldAnnotationWeavingMessage(LazyClassGen clazz, BcelField theField, DeclareAnnotation decaf,
 
1463
                        boolean isRemove) {
1472
1464
                if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
1473
 
                        BcelField theField = (BcelField) fields.get(fieldCounter);
1474
1465
                        world.getMessageHandler().handleMessage(
1475
 
                                        WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] {
1476
 
                                                        theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(), clazz.getFileName(),
1477
 
                                                        decaF.getAnnotationString(), "field", decaF.getAspect().toString(),
1478
 
                                                        Utility.beautifyLocation(decaF.getSourceLocation()) }));
 
1466
                                        WeaveMessage.constructWeavingMessage(
 
1467
                                                        isRemove ? WeaveMessage.WEAVEMESSAGE_REMOVES_ANNOTATION : WeaveMessage.WEAVEMESSAGE_ANNOTATES,
 
1468
                                                        new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
 
1469
                                                                        clazz.getFileName(), decaf.getAnnotationString(), "field", decaf.getAspect().toString(),
 
1470
                                                                        Utility.beautifyLocation(decaf.getSourceLocation()) }));
1479
1471
                }
1480
1472
        }
1481
1473
 
1489
1481
                                if (!reportedProblems.contains(uniqueID)) {
1490
1482
                                        reportedProblems.add(uniqueID);
1491
1483
                                        world.getLint().elementAlreadyAnnotated.signal(new String[] { rm.toString(),
1492
 
                                                        deca.getAnnotationType().toString() }, rm.getSourceLocation(), new ISourceLocation[] { deca
1493
 
                                                        .getSourceLocation() });
 
1484
                                                        deca.getAnnotationType().toString() }, rm.getSourceLocation(),
 
1485
                                                        new ISourceLocation[] { deca.getSourceLocation() });
1494
1486
                                }
1495
1487
                        }
1496
1488
                        return true;
1507
1499
                                        reportedProblems.add(uniqueID);
1508
1500
                                        reportedProblems.add(new Integer(itdfieldsig.hashCode() * deca.hashCode()));
1509
1501
                                        world.getLint().elementAlreadyAnnotated.signal(new String[] { itdfieldsig.toString(),
1510
 
                                                        deca.getAnnotationType().toString() }, rm.getSourceLocation(), new ISourceLocation[] { deca
1511
 
                                                        .getSourceLocation() });
 
1502
                                                        deca.getAnnotationType().toString() }, rm.getSourceLocation(),
 
1503
                                                        new ISourceLocation[] { deca.getSourceLocation() });
1512
1504
                                }
1513
1505
                        }
1514
1506
                        return true;
1534
1526
                return aspectsAffectingType;
1535
1527
        }
1536
1528
 
1537
 
        private boolean inlineSelfConstructors(List methodGens) {
 
1529
        private boolean inlineSelfConstructors(List<LazyMethodGen> methodGens) {
1538
1530
                boolean inlinedSomething = false;
1539
 
                for (Iterator i = methodGens.iterator(); i.hasNext();) {
1540
 
                        LazyMethodGen mg = (LazyMethodGen) i.next();
1541
 
                        if (!mg.getName().equals("<init>")) {
 
1531
                for (LazyMethodGen methodGen : methodGens) {
 
1532
                        if (!methodGen.getName().equals("<init>")) {
1542
1533
                                continue;
1543
1534
                        }
1544
 
                        InstructionHandle ih = findSuperOrThisCall(mg);
 
1535
                        InstructionHandle ih = findSuperOrThisCall(methodGen);
1545
1536
                        if (ih != null && isThisCall(ih)) {
1546
1537
                                LazyMethodGen donor = getCalledMethod(ih);
1547
 
                                inlineMethod(donor, mg, ih);
 
1538
                                inlineMethod(donor, methodGen, ih);
1548
1539
                                inlinedSomething = true;
1549
1540
                        }
1550
1541
                }
1621
1612
        // return new BcelVar(typeX.resolve(world),
1622
1613
        // genTempVarIndex(typeX.getSize()));
1623
1614
        // }
1624
 
        //       
 
1615
        //
1625
1616
        // private int genTempVarIndex(int size) {
1626
1617
        // return enclosingMethod.allocateLocal(size);
1627
1618
        // }
1670
1661
                                // will ensure monitorexit is called. Content on the finally
1671
1662
                                // block seems to
1672
1663
                                // be always:
1673
 
                                // 
 
1664
                                //
1674
1665
                                // E1: ALOAD_1
1675
1666
                                // MONITOREXIT
1676
1667
                                // ATHROW
1788
1779
                                // 32: dup <-- partTwo (branch target)
1789
1780
                                // 33: astore_0
1790
1781
                                // 34: monitorenter
1791
 
                                //                      
 
1782
                                //
1792
1783
                                // plus exceptiontable entry!
1793
1784
                                // 8 13 20 Class java/lang/ClassNotFoundException
1794
1785
                                Type classType = BcelWorld.makeBcelType(synchronizedMethod.getEnclosingClass().getType());
1833
1824
                                InstructionHandle catchInstruction = prepend.getEnd();
1834
1825
                                prepend.append(InstructionFactory.createDup(1));
1835
1826
 
1836
 
                                prepend.append(fact.createPutStatic(synchronizedMethod.getEnclosingClass().getType().getName(), fieldname, Type
1837
 
                                                .getType(Class.class)));
 
1827
                                prepend.append(fact.createPutStatic(synchronizedMethod.getEnclosingClass().getType().getName(), fieldname,
 
1828
                                                Type.getType(Class.class)));
1838
1829
                                prepend.append(InstructionFactory.createBranchInstruction(Constants.GOTO, parttwo.getStart()));
1839
1830
 
1840
1831
                                // start of catch block
1842
1833
                                catchBlockForLiteralLoadingFail.append(fact.createNew((ObjectType) Type.getType(NoClassDefFoundError.class)));
1843
1834
                                catchBlockForLiteralLoadingFail.append(InstructionFactory.createDup_1(1));
1844
1835
                                catchBlockForLiteralLoadingFail.append(InstructionFactory.SWAP);
1845
 
                                catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage", Type
1846
 
                                                .getType(String.class), new Type[] {}, Constants.INVOKEVIRTUAL));
 
1836
                                catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage",
 
1837
                                                Type.getType(String.class), new Type[] {}, Constants.INVOKEVIRTUAL));
1847
1838
                                catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID,
1848
1839
                                                new Type[] { Type.getType(String.class) }, Constants.INVOKESPECIAL));
1849
1840
                                catchBlockForLiteralLoadingFail.append(InstructionFactory.ATHROW);
1871
1862
                                // will ensure monitorexit is called. Content on the finally
1872
1863
                                // block seems to
1873
1864
                                // be always:
1874
 
                                // 
 
1865
                                //
1875
1866
                                // E1: ALOAD_1
1876
1867
                                // MONITOREXIT
1877
1868
                                // ATHROW
1903
1894
                                // search for 'returns' and make them to the
1904
1895
                                // aload_<n>,monitorexit
1905
1896
                                InstructionHandle walker = body.getStart();
1906
 
                                List rets = new ArrayList();
 
1897
                                List<InstructionHandle> rets = new ArrayList<InstructionHandle>();
1907
1898
                                while (walker != null) { // !walker.equals(body.getEnd())) {
1908
1899
                                        if (walker.getInstruction().isReturnInstruction()) {
1909
1900
                                                rets.add(walker);
1915
1906
                                        // the load instruction
1916
1907
                                        // (so we never jump over the monitorexit logic)
1917
1908
 
1918
 
                                        for (Iterator iter = rets.iterator(); iter.hasNext();) {
1919
 
                                                InstructionHandle element = (InstructionHandle) iter.next();
 
1909
                                        for (InstructionHandle ret : rets) {
1920
1910
                                                // System.err.println("Adding monitor exit block at "+
1921
1911
                                                // element);
1922
1912
                                                InstructionList monitorExitBlock = new InstructionList();
1926
1916
                                                // .getInstruction()));
1927
1917
                                                // element.setInstruction(InstructionFactory.createLoad(
1928
1918
                                                // classType,slotForThis));
1929
 
                                                InstructionHandle monitorExitBlockStart = body.insert(element, monitorExitBlock);
 
1919
                                                InstructionHandle monitorExitBlockStart = body.insert(ret, monitorExitBlock);
1930
1920
 
1931
1921
                                                // now move the targeters from the RET to the start of
1932
1922
                                                // the monitorexit block
1933
 
                                                for (InstructionTargeter targeter : element.getTargetersCopy()) {
 
1923
                                                for (InstructionTargeter targeter : ret.getTargetersCopy()) {
1934
1924
                                                        // what kinds are there?
1935
1925
                                                        if (targeter instanceof LocalVariableTag) {
1936
1926
                                                                // ignore
1943
1933
                                                                // monitorExitBlockStart);
1944
1934
                                                        } else if (targeter instanceof InstructionBranch) {
1945
1935
                                                                // move it
1946
 
                                                                targeter.updateTarget(element, monitorExitBlockStart);
 
1936
                                                                targeter.updateTarget(ret, monitorExitBlockStart);
1947
1937
                                                        } else {
1948
1938
                                                                throw new BCException("Unexpected targeter encountered during transform: " + targeter);
1949
1939
                                                        }
1965
1955
 
1966
1956
                                synchronizedMethod.getBody().append(finallyBlock);
1967
1957
                                synchronizedMethod.addExceptionHandler(tryPosition, catchPosition, finallyStart, null/* ==finally */, false);
1968
 
                                synchronizedMethod.addExceptionHandler(tryInstruction, catchInstruction, catchBlockStart, (ObjectType) Type
1969
 
                                                .getType(ClassNotFoundException.class), true);
 
1958
                                synchronizedMethod.addExceptionHandler(tryInstruction, catchInstruction, catchBlockStart,
 
1959
                                                (ObjectType) Type.getType(ClassNotFoundException.class), true);
1970
1960
                                synchronizedMethod.addExceptionHandler(finallyStart, finallyStart.getNext(), finallyStart, null, false);
1971
1961
                        }
1972
1962
                } else {
1992
1982
                        // will ensure monitorexit is called. Content on the finally block
1993
1983
                        // seems to
1994
1984
                        // be always:
1995
 
                        // 
 
1985
                        //
1996
1986
                        // E1: ALOAD_1
1997
1987
                        // MONITOREXIT
1998
1988
                        // ATHROW
2211
2201
                                                        LocalVariableTag lvTag = (LocalVariableTag) old;
2212
2202
                                                        LocalVariableTag lvTagFresh = (LocalVariableTag) fresh;
2213
2203
                                                        if (lvTag.getSlot() == 0) {
2214
 
                                                                fresh = new LocalVariableTag(lvTag.getRealType().getSignature(), "ajc$aspectInstance", frameEnv
2215
 
                                                                                .get(lvTag.getSlot()), 0);
 
2204
                                                                fresh = new LocalVariableTag(lvTag.getRealType().getSignature(), "ajc$aspectInstance",
 
2205
                                                                                frameEnv.get(lvTag.getSlot()), 0);
2216
2206
                                                        } else {
2217
2207
                                                                // // Do not move it - when copying the code from the aspect to the affected target, 'this' is
2218
2208
                                                                // // going to change from aspect to affected type. So just fix the type
2268
2258
        // InstructionList newList = new InstructionList();
2269
2259
        //
2270
2260
        // Map srcToDest = new HashMap();
2271
 
        //                      
 
2261
        //
2272
2262
        // // first pass: copy the instructions directly, populate the srcToDest
2273
2263
        // map,
2274
2264
        // // fix frame instructions
2313
2303
        // }
2314
2304
        // srcToDest.put(src, dest);
2315
2305
        // }
2316
 
        //                      
 
2306
        //
2317
2307
        // // second pass: retarget branch instructions, copy ranges and tags
2318
2308
        // Map tagMap = new HashMap();
2319
2309
        // for (InstructionHandle dest = newList.getStart(), src =
2321
2311
        // dest != null;
2322
2312
        // dest = dest.getNext(), src = src.getNext()) {
2323
2313
        // Instruction inst = dest.getInstruction();
2324
 
        //                              
 
2314
        //
2325
2315
        // // retarget branches
2326
2316
        // if (inst instanceof InstructionBranch) {
2327
2317
        // InstructionBranch branch = (InstructionBranch) inst;
2344
2334
        // }
2345
2335
        // }
2346
2336
        // }
2347
 
        //                              
 
2337
        //
2348
2338
        // //copy over tags and range attributes
2349
2339
        // Iterator tIter = src.getTargeters().iterator();
2350
2340
        //
2446
2436
        }
2447
2437
 
2448
2438
        private void weaveInAddedMethods() {
2449
 
                Collections.sort(addedLazyMethodGens, new Comparator() {
2450
 
                        public int compare(Object a, Object b) {
2451
 
                                LazyMethodGen aa = (LazyMethodGen) a;
2452
 
                                LazyMethodGen bb = (LazyMethodGen) b;
 
2439
                Collections.sort(addedLazyMethodGens, new Comparator<LazyMethodGen>() {
 
2440
                        public int compare(LazyMethodGen aa, LazyMethodGen bb) {
2453
2441
                                int i = aa.getName().compareTo(bb.getName());
2454
2442
                                if (i != 0) {
2455
2443
                                        return i;
2605
2593
                // now add interface inits
2606
2594
                if (!isThisCall(superOrThisCall)) {
2607
2595
                        InstructionHandle curr = enclosingShadow.getRange().getStart();
2608
 
                        for (Iterator i = addedSuperInitializersAsList.iterator(); i.hasNext();) {
2609
 
                                IfaceInitList l = (IfaceInitList) i.next();
 
2596
                        for (Iterator<IfaceInitList> i = addedSuperInitializersAsList.iterator(); i.hasNext();) {
 
2597
                                IfaceInitList l = i.next();
2610
2598
 
2611
2599
                                Member ifaceInitSig = AjcMemberMaker.interfaceConstructor(l.onType);
2612
2600
 
2654
2642
        /**
2655
2643
         * first sorts the mungers, then gens the initializers in the right order
2656
2644
         */
2657
 
        private InstructionList genInitInstructions(List list, boolean isStatic) {
 
2645
        private InstructionList genInitInstructions(List<ConcreteTypeMunger> list, boolean isStatic) {
2658
2646
                list = PartialOrder.sort(list);
2659
2647
                if (list == null) {
2660
2648
                        throw new BCException("circularity in inter-types");
2662
2650
 
2663
2651
                InstructionList ret = new InstructionList();
2664
2652
 
2665
 
                for (Iterator i = list.iterator(); i.hasNext();) {
2666
 
                        ConcreteTypeMunger cmunger = (ConcreteTypeMunger) i.next();
 
2653
                for (ConcreteTypeMunger cmunger : list) {
2667
2654
                        NewFieldTypeMunger munger = (NewFieldTypeMunger) cmunger.getMunger();
2668
2655
                        ResolvedMember initMethod = munger.getInitMethod(cmunger.getAspectType());
2669
2656
                        if (!isStatic) {
2987
2974
                                                annotations = theRealMember.getAnnotationTypes();
2988
2975
                                        }
2989
2976
                                } else if (rm.getKind() == Member.CONSTRUCTOR) {
2990
 
                                        ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world), rm
2991
 
                                                        .getDeclaringType(), rm.getParameterTypes());
 
2977
                                        ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),
 
2978
                                                        rm.getDeclaringType(), rm.getParameterTypes());
2992
2979
                                        ResolvedMember resolvedDooberry = world.resolve(realThing);
2993
2980
                                        // AMC temp guard for M4
2994
2981
                                        if (resolvedDooberry == null) {