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.

IntroducedMethodsOnEachInterface.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import org.aspectj.testing.Tester;
  2. public class IntroducedMethodsOnEachInterface {
  3. public static void main(String[] args) {
  4. new IntroducedMethodsOnEachInterface().realMain(args);
  5. }
  6. public void realMain(String[] args) {
  7. I i0 = new I() { public int j() { return 3; } };
  8. J j0 = new J() { public int j() { return 4; } };
  9. B b0 = new B();
  10. I ib = new B();
  11. J jb = new B();
  12. Tester.checkEqual(i0.j(), 3, "i0");
  13. Tester.checkEqual(j0.j(), 4, "j0");
  14. Tester.checkEqual(b0.j(), 2, "b0");
  15. Tester.checkEqual(ib.j(), 2, "ib");
  16. Tester.checkEqual(jb.j(), 2, "jb");
  17. H h0 = new H() { public int j() { return 7; } };
  18. H ch = new C();
  19. C c0 = new C();
  20. Tester.checkEqual(h0.j(), 7, "h0");
  21. Tester.checkEqual(ch.j(), 6, "ch");
  22. Tester.checkEqual(c0.j(), 6, "c0");
  23. }
  24. }
  25. interface I {}
  26. interface H {}
  27. interface J { public int j(); }
  28. class B implements I {}
  29. class C implements H {}
  30. aspect A {
  31. declare parents: I implements J;
  32. declare parents: H implements I;
  33. declare parents: H implements J;
  34. public int I.j() { return 1; }
  35. public int B.j() { return 2; }
  36. public int H.j() { return 5; }
  37. public int C.j() { return 6; }
  38. }