diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/BindingThisInsteadOfFormal.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/BindingThisInsteadOfFormal.java')
-rw-r--r-- | tests/new/BindingThisInsteadOfFormal.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/new/BindingThisInsteadOfFormal.java b/tests/new/BindingThisInsteadOfFormal.java new file mode 100644 index 000000000..0f7efd4a3 --- /dev/null +++ b/tests/new/BindingThisInsteadOfFormal.java @@ -0,0 +1,57 @@ +import org.aspectj.testing.*; + +public class BindingThisInsteadOfFormal { + public static void main(String[] args) { + Caller c = new Caller(); + c.goo(); + Tester.checkAllEvents(); + } + + static { + Tester.expectEvent("before-string"); + Tester.expectEvent("before-go"); + Tester.expectEvent("before-static"); + Tester.expectEvent("before-c"); + } +} + +class Caller { + void goo() { + go(); + staticGo(); + } + void go() { + String string = new String("string"); + C c = new C(); + } + + static void staticGo() { + } +} + +class C { + +} + +aspect Aspect perthis(this(Caller)) { + pointcut stringCtors(): call(String.new(String)); + before(): stringCtors() { + Tester.event("before-string"); + } + + pointcut cCtors(): call(C.new()); + before(): cCtors() { + Tester.event("before-c"); + } + + pointcut goCalls(Caller caller): call(void go()) && target(caller); + before(Caller caller): goCalls(caller) { + Tester.event("before-go"); + Tester.check(caller != null, "instance method"); + } + + pointcut goStaticCalls(): call(void Caller.staticGo()); + before(): goStaticCalls() { + Tester.event("before-static"); + } +} |