You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CaseS.java 768B

123456789101112131415161718192021222324252627282930313233343536
  1. // TESTING: factory method has incompatible return type - verifyerror if we did use that factory
  2. import org.aspectj.lang.annotation.*;
  3. public class CaseS {
  4. public static void main(String[]argv) {
  5. CaseS cc = new CaseS();
  6. ((I)cc).methodOne(); // will only succeed if mixin applied
  7. }
  8. public String toString() {
  9. return "CaseS instance";
  10. }
  11. }
  12. aspect X {
  13. @DeclareMixin("CaseS")
  14. public static I createImplementation(FooI cf) {
  15. System.out.println(cf instanceof FooI);
  16. System.out.println("Delegate factory invoked for "+cf.toString());
  17. return new Implementation();
  18. }
  19. }
  20. class FooI {
  21. }
  22. interface I {
  23. void methodOne();
  24. }
  25. class Implementation implements I {
  26. public void methodOne() {
  27. System.out.println("methodOne running");
  28. }
  29. }