--- /dev/null
+// TESTING: mixin of a class - should be an error
+import org.aspectj.lang.annotation.*;
+
+public class CaseL {
+ public static void main(String[]argv) {
+ ((C)new CaseL()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin("CaseL")
+ public static C createImplementation1() {return new C();}
+
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
--- /dev/null
+// TESTING: mixin of a class - should be an error
+import org.aspectj.lang.annotation.*;
+
+public class CaseM {
+ public static void main(String[]argv) {
+ }
+}
+
+aspect X {
+ @DeclareMixin("CaseM")
+ public static C createImplementation1() {return new C();}
+
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
--- /dev/null
+// TESTING: factory returns class but interface specified - this is OK
+import org.aspectj.lang.annotation.*;
+
+public class CaseN {
+ public static void main(String[]argv) {
+ ((I)new CaseN()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseN",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+class C implements I {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+}
--- /dev/null
+// TESTING: factory returns class but interface specified - not ok as class doesn't implement interface
+import org.aspectj.lang.annotation.*;
+
+public class CaseO {
+ public static void main(String[]argv) {
+ ((I)new CaseO()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseO",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
--- /dev/null
+// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
+import org.aspectj.lang.annotation.*;
+
+public class CaseP {
+ 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();
+ }
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseP",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}
--- /dev/null
+// TESTING: factory return type implements two interfaces, both should be mixed as specified
+import org.aspectj.lang.annotation.*;
+
+public class CaseQ {
+ public static void main(String[]argv) {
+ ((I)new CaseQ()).foo();
+ ((J)new CaseQ()).goo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseQ",interfaces={I.class,J.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}
--- /dev/null
+// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
+import org.aspectj.lang.annotation.*;
+
+public class CaseP {
+ 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();
+ }
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseP",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}