]> source.dussan.org Git - aspectj.git/commitdiff
pipeline changes: fix for deep nesting aspects
authoraclement <aclement>
Fri, 28 Jul 2006 14:05:39 +0000 (14:05 +0000)
committeraclement <aclement>
Fri, 28 Jul 2006 14:05:39 +0000 (14:05 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/AjPipeliningCompilerAdapter.java
tests/features153/pipelining/DeepAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc153/PipeliningTests.java
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
tests/src/org/aspectj/systemtest/ajc153/pipelining.xml

index 024be56a1b0cf186dd8ec8b368647b9ef436d434..0f37c5f2f97ae59f26be2407817caa0c60591c98 100644 (file)
@@ -539,13 +539,24 @@ public class AjPipeliningCompilerAdapter extends AbstractCompilerAdapter {
                                if (declaration.memberTypes!=null) {
                                        TypeDeclaration[] memberTypes = declaration.memberTypes;
                                        for (int j = 0; j < memberTypes.length; j++) { // loop through inner types
-                                               if (isAspect(memberTypes[j])) return true;
+                                               if (containsAnAspect(memberTypes[j])) return true;
                                        }
                                }
                        }
                }
                return false;
        }
+       
+       private boolean containsAnAspect(TypeDeclaration tDecl) {
+               if (isAspect(tDecl)) return true;
+               if (tDecl.memberTypes!=null) {
+                       TypeDeclaration[] memberTypes = tDecl.memberTypes;
+                       for (int j = 0; j < memberTypes.length; j++) { // loop through inner types
+                               if (containsAnAspect(memberTypes[j])) return true;
+                       }
+               }
+               return false;
+       }
 
        private static final char[] aspectSig = "Lorg/aspectj/lang/annotation/Aspect;".toCharArray();
        private boolean isAspect(TypeDeclaration declaration) {
diff --git a/tests/features153/pipelining/DeepAspect.java b/tests/features153/pipelining/DeepAspect.java
new file mode 100644 (file)
index 0000000..b767ed2
--- /dev/null
@@ -0,0 +1,8 @@
+public class DeepAspect {
+  static class Inner {
+     static aspect SimpleAspect {
+          before(): staticinitialization(Cl*) {
+          }
+     }
+  }
+}
index 01e9430bcaeb6b72922dbdb487c2dbeb633589b9..1e93e77404dd854b28026e2a42a56d568b3e9d7b 100644 (file)
@@ -44,6 +44,7 @@ public class PipeliningTests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testBuildOneAspectTwoClasses() { runTest("build one aspect and two classes");}
        public void testBuildTwoClassesOneAspect() { runTest("build two classes and one aspect");}
        public void testBuildTwoAspects() { runTest("build two aspects");}
+       public void testBuildClassAndNestedAspect() { runTest("build one class and deeply nested aspect");}
        
        public void testAspectExtendsClass() { runTest("aspect extends class"); }
        
index 83e57e87f5442b5e9833ebc1dcd389ef30f4dcee..46b3db42a5f9857c9e9132116413e330e0e09f2d 100644 (file)
      <compile files="hello/HelloWorld.java hello/ThrowExceptionBefore.aj"/>
      <run class="hello.HelloWorld">
                <stderr>
-<!--           
                <line text="hello.HelloWorld.println(HelloWorld.java:13)"/>
--->            
-               <line text="hello.HelloWorld.println(HelloWorld.java)"/>
+               <!--line text="hello.HelloWorld.println(HelloWorld.java)"/-->
                <line text="hello.HelloWorld.testStackTrace(HelloWorld.java:19)"/>
                <line text="hello.HelloWorld.main(HelloWorld.java:41)"/>
                </stderr>
      <compile files="hello/HelloWorld.java hello/ThrowExceptionAround.aj" options="-XnoInline"/>
      <run class="hello.HelloWorld">
                <stderr>
-<!--           
                <line text="hello.HelloWorld.println(HelloWorld.java:13)"/>
--->            
-               <line text="hello.HelloWorld.println(HelloWorld.java:1)"/>
+               <!--line text="hello.HelloWorld.println(HelloWorld.java:1)"/-->
                <line text="hello.HelloWorld.testStackTrace(HelloWorld.java:19)"/>
                <line text="hello.HelloWorld.main(HelloWorld.java:41)"/>
                </stderr>
index 409327ab71c38eb4af1625d0ab732ad0fea121ea..05b85d1f8005d70f73f58b474643ef889f58fd47 100644 (file)
     <ajc-test dir="features153/pipelining" title="recognizing annotation style aspects - 2">
       <compile files="ClassOne.java,AtInnerAJAspect.java" options="-1.5 -verbose"/>
     </ajc-test>
+    
+    <!-- the aspect is multiple layers down in the class... -->
+    <ajc-test dir="features153/pipelining" title="build one class and deeply nested aspect">
+      <compile files="ClassOne.java,DeepAspect.java" options="-1.5 -verbose -showWeaveInfo">
+        <message kind="weave" text="Join point 'staticinitialization(void ClassOne.&lt;clinit&gt;())' in Type 'ClassOne' (ClassOne.java:1) advised by before advice from 'DeepAspect$Inner$SimpleAspect' (DeepAspect.java:4)"/>
+      </compile>
+    </ajc-test>
+    
 
 </suite>
\ No newline at end of file