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/StaticMethodsShouldNotReceiveInstanceofAdvice.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/StaticMethodsShouldNotReceiveInstanceofAdvice.java')
-rw-r--r-- | tests/new/StaticMethodsShouldNotReceiveInstanceofAdvice.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/new/StaticMethodsShouldNotReceiveInstanceofAdvice.java b/tests/new/StaticMethodsShouldNotReceiveInstanceofAdvice.java new file mode 100644 index 000000000..1bc6898a9 --- /dev/null +++ b/tests/new/StaticMethodsShouldNotReceiveInstanceofAdvice.java @@ -0,0 +1,44 @@ +import org.aspectj.testing.*; +import java.util.*; + +public class StaticMethodsShouldNotReceiveInstanceofAdvice { + public static void main(String[] args) { + ClassWithStaticMethods.staticMethod(); + Tester.checkAllEvents(); + } + static { + Tester.expectEventsInString("good0"); + } +} + +class ClassWithStaticMethods { + public static void staticMethod() {} +} + + +aspect PutsAdviceOnStaticMethods { + + static void bad(Object msg) { Tester.check(false, "Shouldn't have seen: " + msg); } + static void good(String msg) { Tester.event(msg); } + + // These shouldn't run + pointcut bad0(): this(ClassWithStaticMethods) && execution(void staticMethod()); + pointcut bad1(ClassWithStaticMethods c): this(c) && execution(void staticMethod()); + pointcut bad2(): target(ClassWithStaticMethods) && call(void staticMethod()); + pointcut bad3(ClassWithStaticMethods c): target(c) && call(void staticMethod()); + pointcut bad4(): target(*) && call(void ClassWithStaticMethods.staticMethod()); + pointcut bad5(ClassWithStaticMethods c): target(c) && call(void staticMethod()); + + before(): bad0() { bad("bad0:" + thisJoinPoint); } + before(ClassWithStaticMethods c): bad1(c) { bad("bad1:" + thisJoinPoint); } + before(): bad2() { bad("bad2:" + thisJoinPoint); } + before(ClassWithStaticMethods c): bad3(c) { bad("bad3:" + thisJoinPoint); } + before(): bad4() { bad("bad4:" + thisJoinPoint); } + before(ClassWithStaticMethods c): bad5(c) { bad("bad5:" + thisJoinPoint); } + + // This should run + pointcut good0(): execution(void ClassWithStaticMethods.staticMethod()); + + before(): good0() { good("good0"); } + +} |