]> source.dussan.org Git - aspectj.git/commitdiff
fix and expanded tests for Bugzilla Bug 39462
authorjhugunin <jhugunin>
Tue, 22 Jul 2003 22:51:34 +0000 (22:51 +0000)
committerjhugunin <jhugunin>
Tue, 22 Jul 2003 22:51:34 +0000 (22:51 +0000)
   Compiler crashes in jar and cflow

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
tests/ajcTests.xml
tests/ajcTestsFailing.xml
tests/bugs/cflowAndJar/AbstractAspect.aj
tests/bugs/cflowAndJar/Test.java
tests/bugs/cflowAndJar/TestAspect.aj
tests/bugs/cflowAndJar/lib.jar
weaver/src/org/aspectj/weaver/ResolvedTypeX.java

index 4b598afcea2465bbea3d8b3138aedae438e9a0ce..e965ea031f031efda50bdc5b268324facfd0478f 100644 (file)
@@ -228,4 +228,8 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName {
                return typeMungers;
        }
 
+       public boolean doesNotExposeShadowMungers() {
+               return true;
+       }
+
 }
index 3f01a7cb633237cc75c38114e8cb077bc3d49196..e133841a25373c0a3621ca2be955d7d31c76573c 100644 (file)
                <message kind="error" line="14"/>
         </compile>
     </ajc-test>
+    
+    <ajc-test dir="bugs/cflowAndJar" pr="39462"
+        title="Compiler crashes in jar and cflow (with no .jar)">
+        <compile files="TestAspect.aj,Test.java,AbstractAspect.aj">
+               <message kind="warning" line="16"/>
+        </compile>
+        <run class="Test"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs/cflowAndJar" pr="39462"
+        title="Compiler crashes in jar and cflow (with .jar)"
+        comment="make lib.jar with ajc -outjar lib.jar AbstractAspect.aj">
+        <compile files="TestAspect.aj,Test.java" aspectpath="lib.jar">
+               <message kind="warning" line="16"/>
+        </compile>
+        <run class="Test"/>
+    </ajc-test>
 </suite>
index 4292bacbde668edfac1b68eac739aef9a3753a53..cb741c1e06e224218dbbdf2f4da77f36dff43413 100644 (file)
@@ -3,11 +3,6 @@
 
 <!-- contains valid tests that the compiler has never passed -->
 <suite>
-    <ajc-test dir="bugs/cflowAndJar" pr="39462"
-        title="Compiler crashes in jar and cflow"
-        comment="make lib.jar with ajc -outjar lib.jar AbstractAspect.aj">
-        <compile files="lib.jar,TestAspect.aj,Test.java"/>
-        <run class="Test"/>
-    </ajc-test>
+
 
 </suite>
index 529cc08b67ba157fc597e5830d7e1900c9e0d357..24e7862139bd4bc59352ef03429a4c4cad363a4a 100644 (file)
@@ -1,6 +1,13 @@
 public abstract aspect AbstractAspect{\r
   public abstract pointcut directCall();\r
+  \r
   before(): directCall(){\r
-    System.out.println("direct");\r
+    noteDirectCall();\r
   }\r
+  \r
+  abstract void noteDirectCall();\r
+  \r
+  public abstract pointcut badCall();\r
+  \r
+  declare warning: badCall(): "bad";\r
 }\r
index 079ac6b22152b581e1ff853ab25c2747f1293f66..9349ca4b0d5c315efcc944fb340c73fdec4fab90 100644 (file)
@@ -1,8 +1,15 @@
-public class Test{
+import org.aspectj.testing.Tester;
+
+public class Test {
   public static void main(String[] arguments){
        Test test = new Test();
-       test.sayHello();
+       Tester.checkEqual(TestAspect.sawDirectCall, false, "no calls");
+       
        test.doSayHello();
+       Tester.checkEqual(TestAspect.sawDirectCall, false, "non-cflow");
+       
+       test.sayHello();
+       Tester.checkEqual(TestAspect.sawDirectCall, true, "in-cflow");
   }
 
   public void sayHello(){
index a6ed50ae6985defbf9cd219bceb3bb3b84d19a1b..78c93e86aa5dbe58fe41627a9df37c494113c564 100644 (file)
@@ -1,6 +1,15 @@
 public aspect TestAspect extends AbstractAspect{\r
   public pointcut directCall():\r
     execution(void Test.doSayHello(..))\r
-    && cflow(execution(void Test.direct(..)))\r
+    && cflow(execution(void Test.sayHello(..)))\r
   ;\r
+  \r
+  public pointcut badCall():\r
+       call(void Test.doSayHello(..)) && withincode(void Test.sayHello(..));\r
+\r
+  void noteDirectCall() {\r
+    sawDirectCall = true;\r
+  }\r
+  \r
+  public static boolean sawDirectCall = false;\r
 }\r
index e80bb93b8058ef5327e8d8b79b2074dd98a9e746..46368f2d2463d78ff1a9d02859d7cee6c43419f6 100644 (file)
Binary files a/tests/bugs/cflowAndJar/lib.jar and b/tests/bugs/cflowAndJar/lib.jar differ
index 9de2348ea7669d9b7552c6b038f9134e9dffa400..12bab5521590bd632d4176f953a6973a6147be79 100644 (file)
@@ -372,7 +372,7 @@ public abstract class ResolvedTypeX extends TypeX {
        
        
     private final Collection collectShadowMungers() {
-        if (! this.isAspect() || this.isAbstract()) return Collections.EMPTY_LIST;
+        if (! this.isAspect() || this.isAbstract() || this.doesNotExposeShadowMungers()) return Collections.EMPTY_LIST;
 
                ArrayList acc = new ArrayList();
         final Iterators.Filter dupFilter = Iterators.dupFilter();
@@ -393,6 +393,10 @@ public abstract class ResolvedTypeX extends TypeX {
         return acc;
     }
     
+       protected boolean doesNotExposeShadowMungers() {
+               return false;
+       }
+
        public PerClause getPerClause() { return null; }
        protected Collection getDeclares() {
                return Collections.EMPTY_LIST; 
@@ -633,6 +637,10 @@ public abstract class ResolvedTypeX extends TypeX {
                public void setStartPos(int startPos) {
                        this.startPos = startPos;
                }
+               
+               public boolean doesNotExposeShadowMungers() {
+                       return delegate.doesNotExposeShadowMungers();
+               }
 
     }
     
@@ -682,6 +690,14 @@ public abstract class ResolvedTypeX extends TypeX {
 //                     return sourceContext;
 //             }
 
+               /**
+                * Designed to be overriden by EclipseType to disable collection of shadow mungers
+                * during pre-weave compilation phase
+                */
+               public boolean doesNotExposeShadowMungers() {
+                       return false;
+               }
+
                public boolean isExposedToWeaver() {
                        return exposedToWeaver;
                }