summaryrefslogtreecommitdiffstats
path: root/tests/new/IntroductionsOverriding.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/IntroductionsOverriding.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/IntroductionsOverriding.java')
-rw-r--r--tests/new/IntroductionsOverriding.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/new/IntroductionsOverriding.java b/tests/new/IntroductionsOverriding.java
new file mode 100644
index 000000000..77fb015bc
--- /dev/null
+++ b/tests/new/IntroductionsOverriding.java
@@ -0,0 +1,59 @@
+import org.aspectj.testing.*;
+
+/** @testcase PR#654 Overriding method implementations using introduction on interfaces */
+public class IntroductionsOverriding {
+ public static void main (String [] args) {
+ (new BaseClass ()).foo("Base");
+ (new DerivedClass ()).foo("Derived");
+ Tester.checkAllEvents();
+ }
+ static {
+ Tester.expectEvent("Derived.foo(\"Derived\")");
+ Tester.expectEvent("Base.foo(\"Base\")");
+ Tester.expectEvent("around call Base");
+ Tester.expectEvent("around execution Base");
+ Tester.expectEvent("around call Base"); // called for both Base+ and Derived+
+ Tester.expectEvent("around execution Base");
+ Tester.expectEvent("around call Derived");
+ Tester.expectEvent("around execution Derived");
+ }
+}
+
+interface Base { public void foo(String s); }
+interface Derived extends Base { public void foo(String s); }
+class DerivedClass implements Derived { }
+class BaseClass implements Base { }
+
+aspect A {
+ public void Base.foo (String arg) {
+ Tester.check("Base".equals(arg),
+ "Base.foo(\"" + arg + "\")");
+ Tester.event("Base.foo(\"" + arg + "\")");
+ }
+ public void Derived.foo (String arg) {
+ Tester.check("Derived".equals(arg),
+ "Derived.foo(\"" + arg + "\")");
+ Tester.event("Derived.foo(\"" + arg + "\")");
+ }
+
+ void around (Base o)
+ : execution (void Base+.foo(..)) // ok if replacing call with execution
+ && target (o) {
+ Tester.event("around execution Base");
+ proceed(o);
+ }
+ void around (Base o)
+ : call (void Base+.foo(..))
+ && target (o) {
+ Tester.event("around call Base");
+ proceed(o);
+ }
+ void around () : call (void Derived+.foo(..)) {
+ Tester.event("around call Derived");
+ proceed();
+ }
+ void around () : execution (void Derived+.foo(..)) {
+ Tester.event("around execution Derived");
+ proceed();
+ }
+}