]> source.dussan.org Git - aspectj.git/commitdiff
fix and test for Bugzilla Bug 34858
authorjhugunin <jhugunin>
Wed, 12 Mar 2003 23:07:08 +0000 (23:07 +0000)
committerjhugunin <jhugunin>
Wed, 12 Mar 2003 23:07:08 +0000 (23:07 +0000)
   Weaver crash

tests/ajcTests.xml
tests/bugs/CflowBinding.java [new file with mode: 0644]
tests/bugs/CflowBindingOrig.java [new file with mode: 0644]
tests/jimTests.xml
weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java

index b8486e3b59c2880aed96639e759c7bfc60395937..40998854bc891cbeda693e493eaf56ca2b49473e 100644 (file)
             <message kind="error" line="85"/>
         </compile>
     </ajc-test>
+    
+    <ajc-test dir="bugs" pr="34858"
+      title="cflow binding issues with ignoring state">
+        <compile files="CflowBinding.java"/>
+        <run class="CflowBinding"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs" pr="34858"
+      title="cflow binding -- original weaver crash">
+        <compile files="CflowBindingOrig.java"/>
+        <run class="CflowBindingOrig"/>
+    </ajc-test>
 </suite>
diff --git a/tests/bugs/CflowBinding.java b/tests/bugs/CflowBinding.java
new file mode 100644 (file)
index 0000000..f127811
--- /dev/null
@@ -0,0 +1,44 @@
+// for Bugzilla Bug 34858  
+//   Weaver crash w/ coverage
+
+import org.aspectj.testing.Tester;
+
+public class CflowBinding {
+       public static void main(String[] args) {
+               new Bar().bar(10);
+       }
+       
+       
+       static aspect A {
+               pointcut flow(int i, Object o): cflow(execution(void bar(int)) && this(o) && args(i));
+               
+               Object around() : call(void m()) && flow(int, Object) {
+                       return proceed();
+               }
+               
+               Object around(final int i) : call(void m()) && flow(i, Object) {
+                       System.out.println("i: " + i);
+                       return proceed(i);
+               }
+               
+               Object around(final Object o) : call(void m()) && flow(int, o) {
+                       System.out.println("o: " + o);
+                       return proceed(o);
+               }
+               
+               Object around(final Object o, final int i) : call(void m()) && flow(i, o) {
+                       System.out.println("o: " + o + ", i: " + i);
+                       return proceed(o, i);
+               }
+       }
+}
+
+class Bar {
+       void bar(int i) {
+               m();
+       }
+       void m() {
+               System.out.println("m");
+       }
+}
+
diff --git a/tests/bugs/CflowBindingOrig.java b/tests/bugs/CflowBindingOrig.java
new file mode 100644 (file)
index 0000000..cd0f00b
--- /dev/null
@@ -0,0 +1,36 @@
+// for Bugzilla Bug 34858  
+//   Weaver crash 
+
+import org.aspectj.testing.Tester;
+
+/**
+ * Almost an exact duplicate of the reported issue
+ */
+public class CflowBindingOrig {
+       public static void main(String[] args) {
+               new Bar().foo();
+       }
+       
+    static aspect MockProcessing {
+        pointcut testFlow(final Thread thread) : 
+            cflow(execution(void run()) && this(thread) && within(Thread)); //  the within is an optimization
+
+        Object around() :
+                call(* DummyConfiguration.createRootApplicationModule(..)) &&  testFlow(Thread)
+        {
+            return null;
+        }
+    }
+}
+
+class Bar {
+    void foo() {
+        DummyConfiguration.createRootApplicationModule();
+    }
+}
+
+class DummyConfiguration {
+    static Object createRootApplicationModule() {
+        return null;
+    }
+}
index f4adb0f97b4169c97f1ff3bb7378fea2527ed510..c03e61f44397a076f3acabbb46e58f31d4091bc7 100644 (file)
@@ -1,7 +1,19 @@
 <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
 <suite>
 
+    <ajc-test dir="errors"  
+               title="type not imported in around advice">
+        <compile files="TypeNotImportedInAroundCE.java">
+               <message kind="error" line="10"/>
+        </compile>
+       </ajc-test>
 
+    <ajc-test dir="errors"  
+               title="type not imported in aspect">
+        <compile files="TypeInAspectNotImportedCE.java">
+               <message kind="error" line="6"/>
+        </compile>
+       </ajc-test>
 
 
     <!--
index 68d9a4e886e0c88a952a1caae9723163f5971646..7345ecffa5f9e4224e07c9e775d7a79edab5a7ee 100644 (file)
@@ -167,6 +167,11 @@ public class CflowPointcut extends Pointcut {
                List slots = new ArrayList();
                for (int i=0, len=freeVars.length; i < len; i++) {
                        int freeVar = freeVars[i];
+                       
+                       // we don't need to keep state that isn't actually exposed to advice
+                       //??? this means that we will store some state that we won't actually use, optimize this later
+                       if (!bindings.hasKey(freeVar)) continue; 
+                       
                        int formalIndex = bindings.get(freeVar);
                        ResolvedTypeX formalType =
                                bindings.getAdviceSignature().getParameterTypes()[formalIndex].resolve(world);