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.

MultiInheritCF.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import org.aspectj.testing.Tester;
  2. public class MultiInheritCF {
  3. public static void main(String[] args) {
  4. C c = new C();
  5. Tester.checkEqual(c.fromRoot(), "Root");
  6. Tester.checkEqual(c.toString(), "I1");
  7. Tester.checkEqual(c.fromI2(), "I2");
  8. Tester.checkEqual(c.fromIRoot0(), "IRoot");
  9. Tester.checkEqual(c.fromIRoot1(), "I1");
  10. Tester.checkEqual(c.fromIRoot2(), "I2");
  11. }
  12. }
  13. abstract class Root {
  14. public String fromRoot() { return "Root"; }
  15. public abstract String fromI2();
  16. public String toString() { return "Root"; }
  17. }
  18. class C extends Root implements I1, I2 {
  19. }
  20. interface IRoot {
  21. }
  22. interface I1 extends IRoot {
  23. public String fromRoot();
  24. }
  25. interface I2 extends IRoot {
  26. }
  27. aspect A {
  28. public String IRoot.fromIRoot0() { return "IRoot"; }
  29. public String IRoot.fromIRoot1() { return "IRoot"; }
  30. public String IRoot.fromIRoot2() { return "IRoot"; }
  31. public String I1.toString() { return "I1"; } //ERR: conflicts with Root
  32. public abstract int I2.toString(); //ERR: conflicts with Root and I1
  33. String I2.fromI2() { return "I2"; } //ERR: weaker than Root
  34. public String I1.fromIRoot1() { return "I1"; }
  35. public String I2.fromIRoot1() { return "I1"; } //ERR: conflicts with I1
  36. }