From: aclement Date: Tue, 28 Mar 2006 07:32:42 +0000 (+0000) Subject: fix for 133298 X-Git-Tag: V1_5_1_final~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d5c7b9f29492554d2255bf44533ffb7515a074b7;p=aspectj.git fix for 133298 --- diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 67b749677..061546114 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -28,8 +28,8 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testAnnotationsAndItds_pr98901() { runTest("annotations and itds");} public void testAnnotationsAndItds_pr98901_2() { runTest("annotations and itds - 2");} public void testCircularGenerics_pr133307() { runTest("circular generics");} - // public void testDeca() { runTest("doubly annotating a method with declare");} - // public void testDeca2() { runTest("doubly annotating a method with declare - 2");} + public void testDeca() { runTest("doubly annotating a method with declare");} + public void testDeca2() { runTest("doubly annotating a method with declare - 2");} public void testCrashingWithASM_pr132926_1() { runTest("crashing on annotation type resolving with asm - 1");} public void testCrashingWithASM_pr132926_2() { runTest("crashing on annotation type resolving with asm - 2");} public void testCrashingWithASM_pr132926_3() { runTest("crashing on annotation type resolving with asm - 3");} diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 27278739c..c6f317d83 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -768,7 +768,7 @@ class BcelClassWeaver implements IClassWeaver { // Single first pass List worthRetrying = new ArrayList(); boolean modificationOccured = false; - + List /*AnnotationGen*/ annotationsToAdd = null; for (Iterator iter = decaMs.iterator(); iter.hasNext();) { DeclareAnnotation decaM = (DeclareAnnotation) iter.next(); @@ -779,15 +779,12 @@ class BcelClassWeaver implements IClassWeaver { unusedDecams.remove(decaM); continue; // skip this one... } - + + if (annotationsToAdd==null) annotationsToAdd = new ArrayList(); Annotation a = decaM.getAnnotationX().getBcelAnnotation(); AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true); - Method oldMethod = mg.getMethod(); - MethodGen myGen = new MethodGen(oldMethod,clazz.getClassName(),clazz.getConstantPoolGen(),false);// dont use tags, they won't get repaired like for woven methods. - myGen.addAnnotation(ag); - Method newMethod = myGen.getMethod(); + annotationsToAdd.add(ag); mg.addAnnotation(decaM.getAnnotationX()); - members.set(memberCounter,new LazyMethodGen(newMethod,clazz)); AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaM.getSourceLocation(),clazz.getName(),mg.getMethod()); reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM,mg.getDeclarationLineNumber()); @@ -815,6 +812,12 @@ class BcelClassWeaver implements IClassWeaver { unusedDecams.remove(decaM); continue; // skip this one... } + + if (annotationsToAdd==null) annotationsToAdd = new ArrayList(); + Annotation a = decaM.getAnnotationX().getBcelAnnotation(); + AnnotationGen ag = new AnnotationGen(a,clazz.getConstantPoolGen(),true); + annotationsToAdd.add(ag); + mg.addAnnotation(decaM.getAnnotationX()); AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaM.getSourceLocation(),clazz.getName(),mg.getMethod()); isChanged = true; @@ -826,6 +829,17 @@ class BcelClassWeaver implements IClassWeaver { } worthRetrying.removeAll(forRemoval); } + if (annotationsToAdd!=null) { + Method oldMethod = mg.getMethod(); + MethodGen myGen = new MethodGen(oldMethod,clazz.getClassName(),clazz.getConstantPoolGen(),false);// dont use tags, they won't get repaired like for woven methods. + for (Iterator iter = annotationsToAdd.iterator(); iter.hasNext();) { + AnnotationGen a = (AnnotationGen) iter.next(); + myGen.addAnnotation(a); + } + Method newMethod = myGen.getMethod(); + members.set(memberCounter,new LazyMethodGen(newMethod,clazz)); + } + } } checkUnusedDeclareAtTypes(unusedDecams, false);