aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs1810/500035/Code3.java
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2016-11-18 09:00:28 -0800
committerAndy Clement <aclement@pivotal.io>2016-11-18 09:00:28 -0800
commitb6f2b6337fbaf95b78c20862cd90f0e027509531 (patch)
treeda38bdf8ab392b0e6f49da7a676a75f885fe9b85 /tests/bugs1810/500035/Code3.java
parente8be95bbfd291f93319d1a1e9920e44cd7eb7569 (diff)
downloadaspectj-b6f2b6337fbaf95b78c20862cd90f0e027509531.tar.gz
aspectj-b6f2b6337fbaf95b78c20862cd90f0e027509531.zip
Fix 500035: handling target only binding in @AJ pointcut
Diffstat (limited to 'tests/bugs1810/500035/Code3.java')
-rw-r--r--tests/bugs1810/500035/Code3.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/bugs1810/500035/Code3.java b/tests/bugs1810/500035/Code3.java
new file mode 100644
index 000000000..48f672991
--- /dev/null
+++ b/tests/bugs1810/500035/Code3.java
@@ -0,0 +1,76 @@
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.*;
+
+@Aspect
+public class Code3 {
+
+ @Around(value = "args(s) && target(targeto) && call(* Foo.run1(String))")
+ public void first(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable {
+ System.out.println("first: binding target, just passing everything through: target=Foo(1)");
+ proceedingJoinPoint.proceed(new Object[]{ targeto, s});
+ }
+
+ @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run2(String))")
+ public void second(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable {
+ System.out.println("second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)");
+ proceedingJoinPoint.proceed(new Object[]{ thiso, targeto, s});
+ }
+
+ @Around(value = "args(s) && this(thiso) && call(* run3(String))")
+ public void third(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable {
+ System.out.println("third: binding this, just passing everything through: this=Foo(0)");
+ proceedingJoinPoint.proceed(new Object[]{ thiso, s});
+ }
+
+ @Around(value = "args(s) && this(thiso) && call(* run4(String))")
+ public void fourth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable {
+ System.out.println("fourth: binding this, switching from Foo(0) to Foo(3)");
+ proceedingJoinPoint.proceed(new Object[]{ new Foo(3), s});
+ }
+
+ @Around(value = "args(s) && target(targeto) && call(* run5(String))")
+ public void fifth(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable {
+ System.out.println("fifth: binding target, switching from Foo(1) to Foo(4)");
+ proceedingJoinPoint.proceed(new Object[]{ new Foo(4), s});
+ }
+
+ @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run6(String))")
+ public void sixth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable {
+ System.out.println("sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))");
+ proceedingJoinPoint.proceed(new Object[]{ targeto, thiso, s});
+ }
+
+ public static void main(String []argv) {
+ new Foo(0).execute1();
+ new Foo(0).execute2();
+ new Foo(0).execute3();
+ new Foo(0).execute4();
+ new Foo(0).execute5();
+ new Foo(0).execute6();
+ }
+}
+
+class Foo {
+ int i;
+ public Foo(int i) {
+ this.i = i;
+ }
+
+ public void execute1() { new Foo(1).run1("abc"); }
+ public void execute2() { new Foo(1).run2("abc"); }
+ public void execute3() { new Foo(1).run3("abc"); }
+ public void execute4() { new Foo(1).run4("abc"); }
+ public void execute5() { new Foo(1).run5("abc"); }
+ public void execute6() { new Foo(1).run6("abc"); }
+
+ public void run1(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+ public void run2(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+ public void run3(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+ public void run4(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+ public void run5(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+ public void run6(String s) { System.out.println("Executing run("+s+") on "+this.toString()); }
+
+ public String toString() {
+ return ("Foo(i="+i+")");
+ }
+}