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.

HasMethodInherited.aj 516B

12345678910111213141516171819202122232425262728
  1. public aspect HasMethodInherited {
  2. declare parents : D && hasmethod(* print(..)) implements Printable;
  3. public static void main(String[] args) {
  4. C c = new C();
  5. if ((c instanceof Printable)) {
  6. throw new RuntimeException("declare parents : hasmethod failed on super");
  7. }
  8. D d = new D();
  9. if (!(d instanceof Printable)) {
  10. throw new RuntimeException("declare parents : hasmethod failed on sub");
  11. }
  12. }
  13. }
  14. class C {
  15. protected void print() {}
  16. }
  17. class D extends C {
  18. }
  19. interface Printable {};