diff options
author | jhugunin <jhugunin> | 2004-01-28 00:36:05 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2004-01-28 00:36:05 +0000 |
commit | 6cceb1b9c3b53e92166d61435f28318e2b9a8872 (patch) | |
tree | be2ceede849425dd4a40f9b103a059190b90d589 /tests/new | |
parent | 098317da0a9bf6b3b12ca3f75c20b74fe42c0374 (diff) | |
download | aspectj-6cceb1b9c3b53e92166d61435f28318e2b9a8872.tar.gz aspectj-6cceb1b9c3b53e92166d61435f28318e2b9a8872.zip |
fix for Bugzilla Bug 49295
duplicate warning or second join point for constructor-execution
Diffstat (limited to 'tests/new')
-rw-r--r-- | tests/new/AfterAdviceOnConstructorsOnTheWrongType.java | 4 | ||||
-rw-r--r-- | tests/new/AfterReturningConstructor.java | 8 | ||||
-rw-r--r-- | tests/new/AfterReturningInterfaceConstructor.java | 11 | ||||
-rw-r--r-- | tests/new/AfterReturningInterfaceConstructorCE.java | 33 | ||||
-rw-r--r-- | tests/new/EmptyInterface.java | 2 | ||||
-rw-r--r-- | tests/new/InitializerTest.java | 10 | ||||
-rw-r--r-- | tests/new/NegativeSourceLocation.java | 4 |
7 files changed, 54 insertions, 18 deletions
diff --git a/tests/new/AfterAdviceOnConstructorsOnTheWrongType.java b/tests/new/AfterAdviceOnConstructorsOnTheWrongType.java index e29ee974a..21ab6cb6b 100644 --- a/tests/new/AfterAdviceOnConstructorsOnTheWrongType.java +++ b/tests/new/AfterAdviceOnConstructorsOnTheWrongType.java @@ -10,8 +10,8 @@ public class AfterAdviceOnConstructorsOnTheWrongType { } static { Tester.clearEvents(); - // new(..) for both class and interface - Tester.expectEventsInString("after-c,after-c,c,after-d,after-d,d"); + // new(..) for just class + Tester.expectEventsInString("after-c,c,after-d,d"); } } diff --git a/tests/new/AfterReturningConstructor.java b/tests/new/AfterReturningConstructor.java index e0fad5e0e..3d87758e5 100644 --- a/tests/new/AfterReturningConstructor.java +++ b/tests/new/AfterReturningConstructor.java @@ -32,8 +32,8 @@ class U { static final String afterThrowing = "after() throwing(): "; static final String c = "C()"; static final String i = "I()"; - static final String cjp = "execution(" + c + ")"; - static final String ijp = "execution(" + i + ")"; + static final String cjp = "initialization(" + c + ")"; + static final String ijp = "initialization(" + i + ")"; static void e(String event) { //System.err.println("act event: " + event); // XXX @@ -46,8 +46,8 @@ class U { } aspect A { - /** must pick out both interface and implementor constructor execution */ - pointcut pc(): execution(new(..)) && !within(A); + /** must pick out both interface and implementor initializers */ + pointcut pc(): initialization(new(..)) && !within(A); before(): pc() { U.e(U.before + thisJoinPoint); diff --git a/tests/new/AfterReturningInterfaceConstructor.java b/tests/new/AfterReturningInterfaceConstructor.java index 71e851867..f16f563bf 100644 --- a/tests/new/AfterReturningInterfaceConstructor.java +++ b/tests/new/AfterReturningInterfaceConstructor.java @@ -6,7 +6,10 @@ public class AfterReturningInterfaceConstructor { public static void main (String[] args) { Tester.expectEvent("constructor"); Tester.expectEvent("advice"); - new C(); + I i = new C(); + + Tester.checkEqual(i.i, 2, "i.i"); + Tester.checkAllEvents(); } } @@ -21,10 +24,10 @@ class C implements I { aspect A { int I.i; - I.new() { - i = 2; + after(I i) returning: this(i) && initialization(I.new(..)) { + i.i = 2; } - after() returning: execution(I.new()) { + after() returning: initialization(I.new(..)) { Tester.event("advice"); } } diff --git a/tests/new/AfterReturningInterfaceConstructorCE.java b/tests/new/AfterReturningInterfaceConstructorCE.java new file mode 100644 index 000000000..aec297d2c --- /dev/null +++ b/tests/new/AfterReturningInterfaceConstructorCE.java @@ -0,0 +1,33 @@ + +import org.aspectj.testing.Tester; + +/** @testcase PR#889 after returning advice on interface constructor */ +public class AfterReturningInterfaceConstructorCE { + public static void main (String[] args) { + Tester.expectEvent("constructor"); + Tester.expectEvent("advice"); + I i = new C(); + System.out.println("i.i: " + i.i); + + Tester.checkAllEvents(); + } +} + +interface I {} + +class C implements I { + C() { + Tester.event("constructor"); + } +} + +aspect A { + int I.i; + I.new() { + i = 2; + System.out.println("running I.new()"); + } + after() returning: execution(I.new()) { // ERR: can't define constructor on interface + Tester.event("advice"); + } +} diff --git a/tests/new/EmptyInterface.java b/tests/new/EmptyInterface.java index aca01b6a8..396f7994c 100644 --- a/tests/new/EmptyInterface.java +++ b/tests/new/EmptyInterface.java @@ -20,7 +20,7 @@ aspect Log { interface LoggedType { } declare parents: C implements LoggedType; - after() : within(LoggedType+) + after(): within(LoggedType+) //&& !initialization(new(..)) //&& !preinitialization(new(..)) // 1.1 only { diff --git a/tests/new/InitializerTest.java b/tests/new/InitializerTest.java index 52f2d93af..31b5ca698 100644 --- a/tests/new/InitializerTest.java +++ b/tests/new/InitializerTest.java @@ -81,10 +81,10 @@ aspect A issingleton () { before(I i): initialization(I.new()) && this(i) { Tester.checkEqual(((C)i).state, "C-constructed", thisJoinPoint.toString()); } - before(I i): execution(I.new()) && this(i) { - Tester.checkEqual(((C)i).state, "C-constructed", thisJoinPoint.toString()); - Tester.note("constructed I"); - } +// before(I i): execution(I.new()) && this(i) { +// Tester.checkEqual(((C)i).state, "C-constructed", thisJoinPoint.toString()); +// Tester.note("constructed I"); +// } after(I i): initialization(I.new()) && this(i) { Tester.checkEqual(((C)i).state, "C-constructed", thisJoinPoint.toString()); Tester.note("initialized I"); @@ -100,7 +100,7 @@ public class InitializerTest { Tester.check("constructed SubC"); Tester.check("initialized I"); - Tester.check("constructed I"); + //Tester.check("constructed I"); Tester.check("static initialized C"); Tester.check("static initialized SubC"); diff --git a/tests/new/NegativeSourceLocation.java b/tests/new/NegativeSourceLocation.java index f76ef229a..f27bf3925 100644 --- a/tests/new/NegativeSourceLocation.java +++ b/tests/new/NegativeSourceLocation.java @@ -287,7 +287,7 @@ class Const { , "before AllTargetJoinPoints set(String TargetClass.staticString)" , "before AllTargetJoinPoints preinitialization(TargetClass())" , "before AllTargetJoinPoints initialization(java.lang.Runnable())" - , "before AllTargetJoinPoints execution(java.lang.Runnable())" + //, "before AllTargetJoinPoints execution(java.lang.Runnable())" , "before AllTargetJoinPoints initialization(TargetClass())" //, "before AllTargetJoinPoints execution(TargetClass.<init>)" , "before AllTargetJoinPoints set(String TargetClass.string)" @@ -305,7 +305,7 @@ class Const { , "before AllTargetJoinPoints preinitialization(TargetClass())" , "before AllTargetJoinPoints initialization(TargetClass())" , "before AllTargetJoinPoints initialization(java.lang.Runnable())" - , "before AllTargetJoinPoints execution(java.lang.Runnable())" + //, "before AllTargetJoinPoints execution(java.lang.Runnable())" //, "before AllTargetJoinPoints execution(TargetClass.<init>)" , "before AllTargetJoinPoints set(String TargetClass.string)" , "before AllTargetJoinPoints execution(TargetClass())" |