diff options
author | Andy Clement <aclement@pivotal.io> | 2022-01-31 15:47:27 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2022-01-31 15:47:27 -0800 |
commit | fab59b5d20ee3ad5d49920c4e9fe785f58820614 (patch) | |
tree | 3b4f99e0e11032b820fd4a197833f0ef215a31db /tests/bugs198 | |
parent | f1cb850e40b98dadfcaf0c6ea27531399a307529 (diff) | |
download | aspectj-fab59b5d20ee3ad5d49920c4e9fe785f58820614.tar.gz aspectj-fab59b5d20ee3ad5d49920c4e9fe785f58820614.zip |
Improve annotation style if pointcut handling
This fixes:
- negating annotation style if() pointcuts doesn't work
- annotation style if() pointcut not able to use a binding
that is not exposed
Fixes #120,#122
Diffstat (limited to 'tests/bugs198')
-rw-r--r-- | tests/bugs198/github_120/C.java | 64 | ||||
-rw-r--r-- | tests/bugs198/github_120/D.java | 33 | ||||
-rw-r--r-- | tests/bugs198/github_122/E.java | 30 |
3 files changed, 127 insertions, 0 deletions
diff --git a/tests/bugs198/github_120/C.java b/tests/bugs198/github_120/C.java new file mode 100644 index 000000000..4af57af24 --- /dev/null +++ b/tests/bugs198/github_120/C.java @@ -0,0 +1,64 @@ +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * This test is exploring situations where an if() pointcut is used with a parameter + * and yet a reference pointcut referring to it is not binding the parameter. + */ +public class C { + + int i; + + C(int i) { + this.i = i; + } + + public static void main(String []argv) { + new C(1).run(); + } + + public void run() { + System.out.println("C.run() executing"); + } + + public String toString() { + return "C("+i+")"; + } + +} + +@Aspect +abstract class Azpect1 { + + @Pointcut("if(false)") + public void isCondition() {} + + @Before("isCondition() && execution(* C.run(..))") + public void beforeAdvice() { + System.out.println("Azpect1.beforeAdvice executing"); + } + +} + +@Aspect +class Azpect2 extends Azpect1 { + @Pointcut("check(*)") + public void isCondition() { } + + @Pointcut("this(c) && if()") + public static boolean check(C c) { + System.out.println("check if() pointcut running on "+c.toString()); + return true; + } +} +// +//abstract aspect A { +// pointcut isCondition(): if(false); +// before(): isCondition() && execution(* C.run(..)) { System.out.println("A.before"); } +//} +// +//aspect B extends A { +// pointcut isCondition(): check(*); +// pointcut check(Object o): this(o) && if(o.toString().equals("abc")); +//}
\ No newline at end of file diff --git a/tests/bugs198/github_120/D.java b/tests/bugs198/github_120/D.java new file mode 100644 index 000000000..2ecdaa574 --- /dev/null +++ b/tests/bugs198/github_120/D.java @@ -0,0 +1,33 @@ +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * This test is exploring situations where an if() pointcut is used with a parameter + * and yet a reference pointcut referring to it is not binding the parameter. + */ +public class D { + + + public static void main(String []argv) { + new D().run(); + } + + public void run() { + System.out.println("D.run() executing"); + } + + public boolean isTrue() { + return true; + } + +} + +@Aspect class Azpect { + + @Pointcut("this(d) && if()") public static boolean method(D d) { return d.isTrue(); } + + @Before("method(*) && execution(* D.run(..))") public void beforeAdvice() { + System.out.println("advice running"); + } +}
\ No newline at end of file diff --git a/tests/bugs198/github_122/E.java b/tests/bugs198/github_122/E.java new file mode 100644 index 000000000..29c818285 --- /dev/null +++ b/tests/bugs198/github_122/E.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +/** + * Test !if() pointcuts + */ +public class E { + + public static void main(String []argv) { + new E().run(); + } + + public void run() { + System.out.println("E.run() executing"); + } + +} + +@Aspect class Azpect { + + @Pointcut("!bar()") + public static void foo() {} + + @Pointcut("if()") public static boolean bar() { return false; } + + @Before("foo() && execution(* E.run(..))") public void beforeAdvice() { + System.out.println("advice running"); + } +}
\ No newline at end of file |