summaryrefslogtreecommitdiffstats
path: root/tests/features164
diff options
context:
space:
mode:
authoraclement <aclement>2009-03-09 22:09:13 +0000
committeraclement <aclement>2009-03-09 22:09:13 +0000
commit596406d0d78771524f4176d807a6791418bfb7b5 (patch)
treeb79a3403ffca0f4459b9aa84ea624d8ff206d39b /tests/features164
parent9c1e8c788a7b5f3856e65815e67bd9209a90ac32 (diff)
downloadaspectj-596406d0d78771524f4176d807a6791418bfb7b5.tar.gz
aspectj-596406d0d78771524f4176d807a6791418bfb7b5.zip
declareMixin
Diffstat (limited to 'tests/features164')
-rw-r--r--tests/features164/declareMixin/CaseR.java26
-rw-r--r--tests/features164/declareMixin/CaseS.java36
-rw-r--r--tests/features164/declareMixin/CaseT.java27
3 files changed, 72 insertions, 17 deletions
diff --git a/tests/features164/declareMixin/CaseR.java b/tests/features164/declareMixin/CaseR.java
index dc12baa4e..854037962 100644
--- a/tests/features164/declareMixin/CaseR.java
+++ b/tests/features164/declareMixin/CaseR.java
@@ -1,29 +1,21 @@
-// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
+// TESTING: testing a pure marker interface - no methods added
import org.aspectj.lang.annotation.*;
-public class CaseP {
+public class CaseR {
public static void main(String[]argv) {
- ((I)new CaseP()).foo();
- CaseP cp = new CaseP();
- if (cp instanceof J) { // should not have been mixed in
- throw new RuntimeException();
- }
+ CaseR cr = new CaseR();
+ System.out.println(cr instanceof I);
+ System.out.println(cr instanceof J);
}
}
aspect X {
- @DeclareMixin(value="CaseP",interfaces={I.class})
- public static C createImplementation1() {return new C();}
-
-}
-
-interface I {
- void foo();
+ @DeclareMixin(value="CaseR",interfaces={I.class})
+ public static C createImplementation1() {return null;}
}
-interface J {
- void goo();
-}
+interface I {}
+interface J {}
class C implements I,J {
public void foo() {
diff --git a/tests/features164/declareMixin/CaseS.java b/tests/features164/declareMixin/CaseS.java
new file mode 100644
index 000000000..aef84923d
--- /dev/null
+++ b/tests/features164/declareMixin/CaseS.java
@@ -0,0 +1,36 @@
+// TESTING: factory method has incompatible return type - verifyerror if we did use that factory
+import org.aspectj.lang.annotation.*;
+
+public class CaseS {
+ public static void main(String[]argv) {
+ CaseS cc = new CaseS();
+ ((I)cc).methodOne(); // will only succeed if mixin applied
+ }
+
+ public String toString() {
+ return "CaseS instance";
+ }
+}
+
+aspect X {
+ @DeclareMixin("CaseS")
+ public static I createImplementation(FooI cf) {
+ System.out.println(cf instanceof FooI);
+ System.out.println("Delegate factory invoked for "+cf.toString());
+ return new Implementation();
+ }
+}
+
+class FooI {
+
+}
+
+interface I {
+ void methodOne();
+}
+
+class Implementation implements I {
+ public void methodOne() {
+ System.out.println("methodOne running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseT.java b/tests/features164/declareMixin/CaseT.java
new file mode 100644
index 000000000..cfddaae0e
--- /dev/null
+++ b/tests/features164/declareMixin/CaseT.java
@@ -0,0 +1,27 @@
+// TESTING: testing a pure marker interface - no methods added
+import org.aspectj.lang.annotation.*;
+
+public class CaseT {
+ public static void main(String[]argv) {
+ CaseT ct = new CaseT();
+ System.out.println(ct instanceof I);
+ System.out.println(ct instanceof J);
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseT",interfaces={I.class})
+ public static C createImplementation1() {return null;}
+}
+
+interface I {}
+interface J {}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}