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.

HasPrivateMethodInherited.aj 520B

12345678910111213141516171819202122232425262728
  1. public aspect HasPrivateMethodInherited {
  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. private void print() {}
  16. }
  17. class D extends C {
  18. }
  19. interface Printable {};