]> source.dussan.org Git - aspectj.git/commitdiff
fixes for 149560: (1) correct the bcel code for creating clinit call (2) don't let...
authoraclement <aclement>
Tue, 22 Aug 2006 15:22:06 +0000 (15:22 +0000)
committeraclement <aclement>
Tue, 22 Aug 2006 15:22:06 +0000 (15:22 +0000)
tests/bugs153/pr149560/AnnStyle.java [new file with mode: 0644]
tests/bugs153/pr149560/CodeStyle.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java

diff --git a/tests/bugs153/pr149560/AnnStyle.java b/tests/bugs153/pr149560/AnnStyle.java
new file mode 100644 (file)
index 0000000..1941e6c
--- /dev/null
@@ -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 (file)
index 0000000..09aaf48
--- /dev/null
@@ -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));
+  }
+}
index b211e5cf3acf298ede57647fd9d0ecff3238d7eb..b366d6798f7cdd4a99dfc0d000cb403d3a6d0ecd 100644 (file)
@@ -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");}
index 06cc9c3713cd90faad9d4ba40bbcad6285f71756..f7586c3423969dc6d744302a87def470bb9ad003 100644 (file)
        </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.&lt;clinit&gt;())' in Type 'MyAspect' (CodeStyle.java:3) advised by after advice from 'MyAspect' (CodeStyle.java:4)"/>
+        <message kind="weave" test="Join point 'staticinitialization(void CodeStyle.&lt;clini&gt;())' 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.&lt;clinit&gt;)"/>
+          <line text="after initialization staticinitialization(CodeStyle.&lt;clinit&gt;)"/>
+          <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.&lt;clinit&gt;())' in Type 'MyAspect' (AnnStyle.java:5) advised by after advice from 'MyAspect' (AnnStyle.java:7)"/>
+        <message kind="weave" test="Join point 'staticinitialization(void AnnStyle.&lt;clini&gt;())' 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.&lt;clinit&gt;)"/>
+          <line text="after initialization staticinitialization(AnnStyle.&lt;clinit&gt;)"/>
+          <line text="InstanceExists?true"/>
+        </stdout>
+      </run>
+    </ajc-test>
+    
 </suite>
\ No newline at end of file
index 3dc02895c60c2c59d6b87c0f0bb99ac38e70af72..e241d5f550a6217568ac5d7ab511c33061947303 100644 (file)
@@ -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);
        }
        
 
index 45104a7a6dbd7c83f64441ed9943a210e367010a..38d385691352cb627664ee3f01f202cb8360792b 100644 (file)
@@ -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
         );
     }
 
index 1c9f6671190434edcc2da37fa40a916e542882df..3852b6a7ad9e96087d3f5102be8c00b7d1275194 100644 (file)
@@ -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