Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

MethodConflictsCP.java 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import org.aspectj.testing.Tester;
  2. public class MethodConflictsCP {
  3. public static void main(String[] args) {
  4. C c = new C();
  5. Tester.checkEqual(c.ma(), "C");
  6. Tester.checkEqual(c.m1(), "I1-C");
  7. Tester.checkEqual(c.m2(), "I2-C");
  8. I1 i1 = c;
  9. Tester.checkEqual(i1.m2(), "I2-C");
  10. Tester.checkEqual(new CO().toString(), "IO");
  11. }
  12. }
  13. class C implements I1, I2 {
  14. public String ma() { return "C"; }
  15. //private void mp() { }
  16. }
  17. interface BaseI {
  18. public String m1();
  19. public String m2();
  20. }
  21. interface I1 extends BaseI {
  22. static aspect BODY {
  23. public String I1.m1() { return "I1-" + ma(); }
  24. public abstract String I1.ma();
  25. }
  26. }
  27. interface I2 extends BaseI {
  28. static aspect BODY {
  29. public String I2.m2() { return "I2-" + ma(); }
  30. public abstract String I2.ma();
  31. private String I2.mp() { return "I2"; }
  32. }
  33. }
  34. interface IO {
  35. static aspect BODY {
  36. public String IO.toString() { return "IO"; }
  37. }
  38. }
  39. class CO implements IO {
  40. }