aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AdviceOnInheritedMethod.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/AdviceOnInheritedMethod.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/AdviceOnInheritedMethod.java')
-rw-r--r--tests/new/AdviceOnInheritedMethod.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/new/AdviceOnInheritedMethod.java b/tests/new/AdviceOnInheritedMethod.java
new file mode 100644
index 000000000..2733250a3
--- /dev/null
+++ b/tests/new/AdviceOnInheritedMethod.java
@@ -0,0 +1,64 @@
+
+import org.aspectj.testing.Tester;
+
+import org.aspectj.lang.*;
+
+public aspect AdviceOnInheritedMethod {
+ public static void main(String[] args) { test(); }
+
+ public static void test() {
+ SuperC sc = new SubC();
+ Tester.checkEqual(sc.doIt(":foo"),
+ ":foo:beforeDoIt:inSubC:foo:beforeDoIt1:inSubC:doIt1",
+ "SubC.doIt");
+ Tester.checkEqual(new SuperC().doIt(":foo"),
+ ":foo:beforeDoIt1:inSuperC:doIt1",
+ "SuperC.doIt");
+ Tester.checkEqual(new SubC().packageDoIt(":foo"),
+ ":foo:beforePackageDoIt:inSubC:foo",
+ "SubC.packageDoIt");
+ }
+
+ String getTargetName(JoinPoint thisJoinPoint) {
+ return thisJoinPoint.getTarget().getClass().getName();
+ }
+
+ String around(String a):
+ target(*) && call(String packageDoIt(String)) && args(a)
+ {
+ return a+
+ ":beforePackageDoIt:in"+getTargetName(thisJoinPoint)
+ + proceed(a);
+ }
+ String around(String a):
+ target(SubC) && call(String doIt(String)) && args(a) {
+ return a+
+ ":beforeDoIt:in"+getTargetName(thisJoinPoint)
+ + proceed(a);
+ }
+ String around(String a):
+ target(SuperC) && call(String doIt1(String)) && args(a) {
+ return a+
+ ":beforeDoIt1:in"+getTargetName(thisJoinPoint)
+ + proceed(a);
+ }
+}
+
+class SuperC {
+ public String doIt(String arg) {
+ return doIt1(arg);
+ }
+ protected String doIt1(String arg) {
+ return ":doIt1";
+ }
+ String packageDoIt(String arg) {
+ return arg;
+ }
+}
+
+class SubC extends SuperC {
+ public String doIt(String arg) {
+ return super.doIt(arg);
+ }
+}
+