diff options
author | aclement <aclement> | 2004-05-18 15:54:05 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-05-18 15:54:05 +0000 |
commit | 68bc96dd1086d5832e96395b09f49da2b8e5f995 (patch) | |
tree | 591d5c30fa87b8e8c26dc1bb56f436f5aa15e9c9 /tests/bugs | |
parent | b8d69e0fb755e3565831662007cef08118b24bd5 (diff) | |
download | aspectj-68bc96dd1086d5832e96395b09f49da2b8e5f995.tar.gz aspectj-68bc96dd1086d5832e96395b09f49da2b8e5f995.zip |
Tests for Bugzilla Bug 62458
An if() pointcut inside a perthis() clause causes an ABORT - null pointer exception in ajc
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/IfPerThis/Testcase1.java | 27 | ||||
-rw-r--r-- | tests/bugs/IfPerThis/Testcase2.java | 41 | ||||
-rw-r--r-- | tests/bugs/IfPerThis/Testcase3.java | 37 |
3 files changed, 105 insertions, 0 deletions
diff --git a/tests/bugs/IfPerThis/Testcase1.java b/tests/bugs/IfPerThis/Testcase1.java new file mode 100644 index 000000000..38ea7b16c --- /dev/null +++ b/tests/bugs/IfPerThis/Testcase1.java @@ -0,0 +1,27 @@ +public class Testcase1 { + + public static void main(String [] args) { + new Testcase1().sayhi(); + } + + public void sayhi() { + System.out.println("Hello World"); + } + +} + +// Note the use of an if inside a perthis, causes the ajc compiler to +// throw an exception +aspect Aspect perthis(if(4==3)) { + + before () : call(* println(..)) && !within(Aspect*) { + System.out.println("Advice 1"); + } + +} + +aspect Aspect2 pertarget(if(3==4)) {} + +aspect Aspect3 percflow(if(3==4)) {} + +aspect Aspect4 percflowbelow(if(3==4)) {}
\ No newline at end of file diff --git a/tests/bugs/IfPerThis/Testcase2.java b/tests/bugs/IfPerThis/Testcase2.java new file mode 100644 index 000000000..42e9dfb04 --- /dev/null +++ b/tests/bugs/IfPerThis/Testcase2.java @@ -0,0 +1,41 @@ + aspect Testcase2 perthis(pc1()) { + + pointcut pc1(): execution(* doCommand(..)) && if(commandInterceptionEnabled); + private static boolean commandInterceptionEnabled = true; + + public Testcase2() { + System.out.println("Created a PerThis aspect : " + this.toString()); + } + + before(ICommand command) : execution(* doCommand(..)) && this(command) { + System.out.println("Invoking command bean: "+ command); + } + + before(): if(4==3) { + + } + + public static void main(String[] args) { + ICommand c1 = new Command("hello"); + ICommand c2 = new Command("hello again"); + c1.doCommand(); + c2.doCommand(); + } + +} + +interface ICommand { + void doCommand(); +} + +class Command implements ICommand { + + private String output = ""; + + public Command(String s) { this.output = s; } + + public void doCommand() { + System.out.println(output + "(" + this + ")"); + } + +}
\ No newline at end of file diff --git a/tests/bugs/IfPerThis/Testcase3.java b/tests/bugs/IfPerThis/Testcase3.java new file mode 100644 index 000000000..c29834338 --- /dev/null +++ b/tests/bugs/IfPerThis/Testcase3.java @@ -0,0 +1,37 @@ +// Compiler limitation, can't put if() directly in per clause +aspect Testcase3 perthis(execution(* doCommand(..)) && if(commandInterceptionEnabled)) { + + private static boolean commandInterceptionEnabled = true; + + public Testcase3() { + System.out.println("Created a PerThis aspect : " + this.toString()); + } + + before(ICommand command) : execution(* doCommand(..)) && this(command) { + System.out.println("Invoking command bean: "+ command); + } + + public static void main(String[] args) { + ICommand c1 = new Command("hello"); + ICommand c2 = new Command("hello again"); + c1.doCommand(); + c2.doCommand(); + } + +} + +interface ICommand { + void doCommand(); +} + +class Command implements ICommand { + + private String output = ""; + + public Command(String s) { this.output = s; } + + public void doCommand() { + System.out.println(output + "(" + this + ")"); + } + +}
\ No newline at end of file |