]> source.dussan.org Git - aspectj.git/commitdiff
Tests for Bugzilla Bug 62073
authoraclement <aclement>
Fri, 14 May 2004 09:27:42 +0000 (09:27 +0000)
committeraclement <aclement>
Fri, 14 May 2004 09:27:42 +0000 (09:27 +0000)
   false ambigous binding error (introduced in 1.2rc2)

tests/ajcTests.xml
tests/bugs/DisjunctVarBinding_2.java [new file with mode: 0644]
tests/bugs/DisjunctVarBinding_3.java [new file with mode: 0644]

index 35742e80c536c58e4711637017227b9e548d1255..d30ddb380dfc6d3f753cb65312c434d2fff01ad8 100644 (file)
     <ajc-test dir="bugs"
                pr="61568" title="wrong variable binding in || pointcuts">
         <compile files="DisjunctVarBinding.java">
-          <message kind="error" line="18" text="Ambiguous binding of type B"/>
-          <message kind="error" line="18" text="Ambiguous binding of type A"/>
+          <message kind="error" line="34" text="Ambiguous binding of type B"/>
+          <message kind="error" line="34" text="Ambiguous binding of type A"/>
         </compile>
     </ajc-test>
  
           <message kind="warning" line="10" text="no interface constructor-execution join point"/>
         </compile>
     </ajc-test>
+    
+       <ajc-test dir="bugs"
+               pr="62073" title="false ambigous binding error (introduced in 1.2rc2)">
+        <compile files="DisjunctVarBinding_2.java,DisjunctVarBinding_3.java">
+               <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type B"/>
+               <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type A"/>
+        </compile>
+        <compile files="DisjunctVarBinding_3.java,DisjunctVarBinding_2.java">
+               <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type B"/>
+               <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type A"/>
+        </compile>
+    </ajc-test>
  
 </suite>
diff --git a/tests/bugs/DisjunctVarBinding_2.java b/tests/bugs/DisjunctVarBinding_2.java
new file mode 100644 (file)
index 0000000..30a96bd
--- /dev/null
@@ -0,0 +1,67 @@
+class A {
+       void m() {
+               System.out.println("A");
+       }
+ }
+
+class B extends A {
+               void m() {
+               System.out.println("B");
+       }
+ }
+
+
+
+public class DisjunctVarBinding_2 { 
+
+       public static void foo(A a, A b) {
+           a.m();
+               b.m();
+       }
+
+       public static void main(String[] args) {
+               A a = new A();
+               B b = new B(); 
+               foo(b,a); 
+       } 
+}
+
+/* Example to illustrate a problem with variable
+   binding and (||) in pointcuts. When run, this program produces
+   java.lang.ClassCastException immediately after
+   the call to "foo". 
+
+   The reason is that the instance tests inherent
+   in the pointcut are done separately from the
+   variable binding.
+
+   Decompiled, the code produced for the relevant call
+   to "foo" is as follows:
+   
+   -------------------------------------------------- 
+   DisjunctVarBinding.foo(r5, r4);
+   label_0:
+        {
+            if (r5 instanceof B == false)
+            {
+                if (r4 instanceof B == false)
+                {
+                    break label_0;
+                }
+            }
+
+            IfPointcut.aspectOf().ajc$afterReturning$IfPointcut$26d(r5, (B) r4);
+        }
+   --------------------------------------------------
+   It should however read something like this, using the instance
+   tests to determine the appropriate variable binding
+
+   --------------------------------------------------
+   DisjunctVarBinding.foo(r5,r4);
+   if (r4 instanceof B)
+      IfPointcut.aspectOf().ajc$afterReturning$IfPointcut$26d(r5, (B)r4)
+   else if (r5 instanceof A)
+           IfPointcut.aspectOf().ajc$afterReturning$IfPointcut$26d(r4,(B)r5)
+   --------------------------------------------------
+*/
\ No newline at end of file
diff --git a/tests/bugs/DisjunctVarBinding_3.java b/tests/bugs/DisjunctVarBinding_3.java
new file mode 100644 (file)
index 0000000..3876b35
--- /dev/null
@@ -0,0 +1,8 @@
+aspect IfPointcut { 
+
+       after(A a, B b) returning:
+          call(* foo(*,*)) && 
+       (args(b,a) || args(a,b)) { 
+               System.out.println("Woven"); 
+       }
+}
\ No newline at end of file