aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authoraclement <aclement>2004-05-14 09:27:42 +0000
committeraclement <aclement>2004-05-14 09:27:42 +0000
commit7051338a0064c3a43223e26e3ace8b64258200d7 (patch)
treebd2c3409b46870df6b8efcff357d37b1e3954b0d /tests/bugs
parent66818c77ef60abcd8562e0482fe44541ad185c0a (diff)
downloadaspectj-7051338a0064c3a43223e26e3ace8b64258200d7.tar.gz
aspectj-7051338a0064c3a43223e26e3ace8b64258200d7.zip
Tests for Bugzilla Bug 62073
false ambigous binding error (introduced in 1.2rc2)
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/DisjunctVarBinding_2.java67
-rw-r--r--tests/bugs/DisjunctVarBinding_3.java8
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/bugs/DisjunctVarBinding_2.java b/tests/bugs/DisjunctVarBinding_2.java
new file mode 100644
index 000000000..30a96bd93
--- /dev/null
+++ b/tests/bugs/DisjunctVarBinding_2.java
@@ -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
index 000000000..3876b3521
--- /dev/null
+++ b/tests/bugs/DisjunctVarBinding_3.java
@@ -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