summaryrefslogtreecommitdiffstats
path: root/tests/new/OverridingPointcuts.java
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/OverridingPointcuts.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/OverridingPointcuts.java')
-rw-r--r--tests/new/OverridingPointcuts.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/new/OverridingPointcuts.java b/tests/new/OverridingPointcuts.java
new file mode 100644
index 000000000..a07815baf
--- /dev/null
+++ b/tests/new/OverridingPointcuts.java
@@ -0,0 +1,60 @@
+import org.aspectj.testing.Tester;
+
+public class OverridingPointcuts {
+ public static void main(String[] args) {
+ C c1 = new C();
+ C c2 = new C();
+
+ c1.m1();
+ c2.m2();
+
+ Tester.checkEqual(c1.m1(), "A1-m1");
+ Tester.checkEqual(c2.m2(), "m2");
+
+ Tester.checkEqual(c1.m3(), "A1-m3");
+ Tester.checkEqual(c2.m3(), "m3");
+
+ Tester.check(!A2.hasAspect(c1), "c1 hasa A2");
+ Tester.check(A1.hasAspect(c1), "c1 hasa A1");
+
+ Tester.check(A2.hasAspect(c2), "c2 hasa A2");
+ Tester.check(!A1.hasAspect(c2), "!c2 hasa A1");
+ }
+}
+
+
+class C {
+ public String m1() { return "m1"; }
+ public String m2() { return "m2"; }
+ public String m3() { return "m3"; }
+}
+
+abstract aspect A pertarget(target(C) && call(String m2())) {
+ int cached;
+
+ abstract pointcut testpoint();
+
+ String modifyResult(String r) { return "A-" + r; }
+
+ String around (): testpoint() {
+ return modifyResult(proceed());
+ }
+}
+
+aspect A1 extends A pertarget(target(C) && call(String m1())) {
+ pointcut testpoint() : call(String C.*(..));
+
+ String modifyResult(String s) { return "A1-" + s; }
+}
+
+aspect A2 extends A {
+ pointcut testpoint();
+}
+
+/*
+public aspect A2 extends A of eachobject(instanceof(C) && receptions(String m2())) {
+ pointcut testpoint() returns String: receptions(String *(..));
+
+ String modifyResult(String s) { return "A2-" + s; }
+}
+*/