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.

ParentUsingChild.java 802B

1234567891011121314151617181920212223242526
  1. import org.aspectj.testing.*;
  2. /** @testcase PUREJAVA PR#728 interface using preceding subinterface in its definition (order matters) */
  3. interface Child extends Parent {
  4. interface Toy { }
  5. }
  6. interface Parent { // order matters - must be after Child
  7. Child.Toy battle();
  8. }
  9. public class ParentUsingChild {
  10. public static void main (String[] args) {
  11. Tester.check(Parent.class.isAssignableFrom(Child.class),
  12. "!Parent.class.isAssignableFrom(Child.class)");
  13. Parent p = new Parent() {
  14. public Child.Toy battle() {
  15. return new Child.Toy(){};
  16. }
  17. };
  18. Child.Toy battle = p.battle();
  19. Tester.check(battle instanceof Child.Toy,
  20. "!battle instanceof Child.Toy");
  21. }
  22. }