diff options
Diffstat (limited to 'tests/design/pcds/If.java')
-rw-r--r-- | tests/design/pcds/If.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/design/pcds/If.java b/tests/design/pcds/If.java new file mode 100644 index 000000000..8d843e36d --- /dev/null +++ b/tests/design/pcds/If.java @@ -0,0 +1,52 @@ +public class If { + public static void main(String[] args) { + C c = new C(); + c.m(true); + c.m(false); + c.m(true); + c.m(false); + } +} + +class C { + static boolean test() { return value; } + + static boolean value = false; + + void m(boolean b) { + value = b; + System.out.println("C.m(" + b + ")"); + } +} + +aspect A { + static boolean testA() { return true; } + boolean itestA() { return true; } + + boolean t = true; + + before(): call(void m(boolean)) && if(C.test()) { + System.out.println(thisJoinPoint); + } + before(boolean x): call(void m(boolean)) && args(x) && if(x) && if(testA()) && if(this.t) && + if(thisJoinPoint.getSignature().getName().equals("m")) && if(itestA()) { + System.out.println(x + ": " + thisJoinPoint); + } + + pointcut cut(boolean a): call(void m(boolean)) && args(a) && if(a) && if(this.itestA()) && if(t); + + before(boolean x): cut(x) { + System.out.println(x); + } + + before(Object t): target(t) && call(void m(boolean)) && if(t instanceof C) { + System.out.println(t); + } + before(Object t): target(t) && call(void m(boolean)) && if(t instanceof String) { + System.out.println(t); + } + + before(C c): target(c) && call(void m(boolean)) && if(c.value) { + System.out.println(thisJoinPoint); + } +} |