diff options
author | aclement <aclement> | 2006-08-22 15:22:06 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-08-22 15:22:06 +0000 |
commit | 945a257776a5879251ccb1b90cf24fd1d89bcfe6 (patch) | |
tree | 43cf57a61f1a23af4bc9be81d02d2234901eba93 | |
parent | 41af7600c8661ff5b7a66a1e97fb865b562bc296 (diff) | |
download | aspectj-945a257776a5879251ccb1b90cf24fd1d89bcfe6.tar.gz aspectj-945a257776a5879251ccb1b90cf24fd1d89bcfe6.zip |
fixes for 149560: (1) correct the bcel code for creating clinit call (2) don't let singleton aspects be implemented as late type mungers, the clinit manipulation breaks.
7 files changed, 82 insertions, 9 deletions
diff --git a/tests/bugs153/pr149560/AnnStyle.java b/tests/bugs153/pr149560/AnnStyle.java new file mode 100644 index 000000000..1941e6ca7 --- /dev/null +++ b/tests/bugs153/pr149560/AnnStyle.java @@ -0,0 +1,20 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +class MyAspect { + @After("staticinitialization(*)") + public void x(JoinPoint.StaticPart thisJoinPointStaticPart) { + System.out.println("after initialization "+thisJoinPointStaticPart); + } +} + +public aspect AnnStyle { + + static { + } + + public static void main(String []argv) { + System.out.println("InstanceExists?"+Aspects.hasAspect(MyAspect.class)); + } +} diff --git a/tests/bugs153/pr149560/CodeStyle.java b/tests/bugs153/pr149560/CodeStyle.java new file mode 100644 index 000000000..09aaf48cd --- /dev/null +++ b/tests/bugs153/pr149560/CodeStyle.java @@ -0,0 +1,17 @@ +import org.aspectj.lang.*; + +aspect MyAspect { + after(): staticinitialization(*) { + System.out.println("after initialization "+thisJoinPointStaticPart); + } +} + +public aspect CodeStyle { + + static { + } + + public static void main(String []argv) { + System.out.println("InstanceExists?"+Aspects.hasAspect(MyAspect.class)); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java index b211e5cf3..b366d6798 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java @@ -27,7 +27,9 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");} // public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); } // public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");} - public void testIncorrectDeprecatedAnnotationProcessing_pr154332() { runTest("incorrect deprecated annotation processing");} + public void testIncorrectStaticinitializationWeaving_pr149560_1() { runTest("incorrect staticinitialization weaving - codestyle");} + public void testIncorrectStaticinitializationWeaving_pr149560_2() { runTest("incorrect staticinitialization weaving - annstyle");} + public void testIncorrectDeprecatedAnnotationProcessing_pr154332() { runTest("incorrect deprecated annotation processing");} public void testPipeliningProblemWithAnnotationsDecp_pr153380_1() { runTest("pipelining decps");} public void testUnwantedPointcutWarning_pr148219() { runTest("unwanted warning for pointcut");} public void testDecpAndCflowadderMungerClash_pr152631() { runTest("decp and cflowadder munger clash");} diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml index 06cc9c371..f7586c342 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml +++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml @@ -305,4 +305,32 @@ </run> </ajc-test> + <ajc-test dir="bugs153/pr149560" title="incorrect staticinitialization weaving - codestyle"> + <compile files="CodeStyle.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'staticinitialization(void MyAspect.<clinit>())' in Type 'MyAspect' (CodeStyle.java:3) advised by after advice from 'MyAspect' (CodeStyle.java:4)"/> + <message kind="weave" test="Join point 'staticinitialization(void CodeStyle.<clini>())' in Type 'CodeStyle' (CodeStyle.java:9) advised by after advice from 'MyAspect' (CodeStyle.java:4)"/> + </compile> + <run class="CodeStyle"> + <stdout> + <line text="after initialization staticinitialization(MyAspect.<clinit>)"/> + <line text="after initialization staticinitialization(CodeStyle.<clinit>)"/> + <line text="InstanceExists?true"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs153/pr149560" title="incorrect staticinitialization weaving - annstyle"> + <compile files="AnnStyle.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'staticinitialization(void MyAspect.<clinit>())' in Type 'MyAspect' (AnnStyle.java:5) advised by after advice from 'MyAspect' (AnnStyle.java:7)"/> + <message kind="weave" test="Join point 'staticinitialization(void AnnStyle.<clini>())' in Type 'AnnStyle' (AnnStyle.java:12) advised by after advice from 'MyAspect' (AnnStyle.java:7)"/> + </compile> + <run class="AnnStyle"> + <stdout> + <line text="after initialization staticinitialization(MyAspect.<clinit>)"/> + <line text="after initialization staticinitialization(AnnStyle.<clinit>)"/> + <line text="InstanceExists?true"/> + </stdout> + </run> + </ajc-test> + </suite>
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 3dc02895c..e241d5f55 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -658,16 +658,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertTrue("Should be zero but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==0); alter("PR141956","inc1"); build("PR141956"); - assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1); + assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2); alter("PR141956","inc1"); build("PR141956"); - assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1); + assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2); alter("PR141956","inc1"); build("PR141956"); - assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1); + assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2); alter("PR141956","inc1"); build("PR141956"); - assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1); + assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2); } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java index 45104a7a6..38d385691 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java @@ -264,7 +264,7 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger { clinit.getBody().append(il); clinit.addExceptionHandler( - tryStart, handler, handler, new ObjectType("java.lang.Throwable"), false + tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Throwable"), false ); } diff --git a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java index 1c9f66711..3852b6a7a 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java @@ -107,9 +107,15 @@ public class PerSingleton extends PerClause { if (inAspect.isAnnotationStyleAspect() && !inAspect.isAbstract()) { //TODO will those change be ok if we add a serializable aspect ? // dig: "can't be Serializable/Cloneable unless -XserializableAspects" - inAspect.crosscuttingMembers.addLateTypeMunger( - inAspect.getWorld().makePerClauseAspect(inAspect, getKind()) - ); + if (getKind()==SINGLETON) { // pr149560 + inAspect.crosscuttingMembers.addTypeMunger( + inAspect.getWorld().makePerClauseAspect(inAspect, getKind()) + ); + } else { + inAspect.crosscuttingMembers.addLateTypeMunger( + inAspect.getWorld().makePerClauseAspect(inAspect, getKind()) + ); + } } //ATAJ inline around advice support |