diff options
author | Andy Clement <aclement@pivotal.io> | 2016-11-18 09:00:28 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2016-11-18 09:00:28 -0800 |
commit | b6f2b6337fbaf95b78c20862cd90f0e027509531 (patch) | |
tree | da38bdf8ab392b0e6f49da7a676a75f885fe9b85 /tests/bugs1810 | |
parent | e8be95bbfd291f93319d1a1e9920e44cd7eb7569 (diff) | |
download | aspectj-b6f2b6337fbaf95b78c20862cd90f0e027509531.tar.gz aspectj-b6f2b6337fbaf95b78c20862cd90f0e027509531.zip |
Fix 500035: handling target only binding in @AJ pointcut
Diffstat (limited to 'tests/bugs1810')
-rw-r--r-- | tests/bugs1810/500035/Code.java | 30 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code2.java | 30 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code3.java | 76 | ||||
-rw-r--r-- | tests/bugs1810/500035/Code4.java | 35 | ||||
-rw-r--r-- | tests/bugs1810/501656/ApplicationException.java | 9 | ||||
-rw-r--r-- | tests/bugs1810/501656/ApplicationExceptionHandler.java | 17 | ||||
-rw-r--r-- | tests/bugs1810/501656/Code.java | 4 | ||||
-rw-r--r-- | tests/bugs1810/501656/out/com/myapp/ApplicationException.class | bin | 0 -> 499 bytes |
8 files changed, 201 insertions, 0 deletions
diff --git a/tests/bugs1810/500035/Code.java b/tests/bugs1810/500035/Code.java new file mode 100644 index 000000000..58e738da4 --- /dev/null +++ b/tests/bugs1810/500035/Code.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) " +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","7"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code2.java b/tests/bugs1810/500035/Code2.java new file mode 100644 index 000000000..23eddce7e --- /dev/null +++ b/tests/bugs1810/500035/Code2.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code2 { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) && this(c)" +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, Code2 c, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ c, targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code2().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","8"); + System.out.println(s); + } + +} 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+")"); + } +} diff --git a/tests/bugs1810/500035/Code4.java b/tests/bugs1810/500035/Code4.java new file mode 100644 index 000000000..176ce2011 --- /dev/null +++ b/tests/bugs1810/500035/Code4.java @@ -0,0 +1,35 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +public aspect Code4 { + + void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) { + System.out.println("first: binding target, just passing everything through"); + proceed(targeto, s); + } + + public static void main(String []argv) { + new Foo(0).execute(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + f1.run("abc"); + } + + public void run(String s) { + System.out.println("Executing run("+s+") on "+this.toString()); + } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/501656/ApplicationException.java b/tests/bugs1810/501656/ApplicationException.java new file mode 100644 index 000000000..5392eeaef --- /dev/null +++ b/tests/bugs1810/501656/ApplicationException.java @@ -0,0 +1,9 @@ +package com.myapp; + +public class ApplicationException extends Exception { + private static final long serialVersionUID = 1L; + + public ApplicationException(String message) { + super(message); + } +} diff --git a/tests/bugs1810/501656/ApplicationExceptionHandler.java b/tests/bugs1810/501656/ApplicationExceptionHandler.java new file mode 100644 index 000000000..bd96e1c27 --- /dev/null +++ b/tests/bugs1810/501656/ApplicationExceptionHandler.java @@ -0,0 +1,17 @@ +package com.myapp.aspect; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; + +import com.myapp.ApplicationException; + +@Aspect +public abstract class ApplicationExceptionHandler<EX extends ApplicationException> { + @AfterThrowing( + pointcut = "execution(* com.myapp.*.facade.*.*(..))", + throwing = "exception" +, argNames="exception" + ) + public abstract void handleFacadeException(EX exception); + +} diff --git a/tests/bugs1810/501656/Code.java b/tests/bugs1810/501656/Code.java new file mode 100644 index 000000000..c8e603a9e --- /dev/null +++ b/tests/bugs1810/501656/Code.java @@ -0,0 +1,4 @@ +public abstract class Code { + public void m(String str1) {} + public abstract void m2(String str2); +} diff --git a/tests/bugs1810/501656/out/com/myapp/ApplicationException.class b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class Binary files differnew file mode 100644 index 000000000..fbbbdda19 --- /dev/null +++ b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class |