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.

BindingInterfaces.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. import java.util.*;
  3. public class BindingInterfaces {
  4. public static void main(String[] args) {
  5. new BindingInterfaces().realMain(args);
  6. }
  7. public void realMain(String[] args) {
  8. I i0 = new I(){}; Tester.checkEqual(str(i0), "I", "i0");
  9. I ij = new J(){}; Tester.checkEqual(str(ij), "JI", "ij");
  10. I ik = new K(){}; Tester.checkEqual(str(ik), "KJI", "ik");
  11. J j0 = new J(){}; Tester.checkEqual(str(j0), "JI", "j0");
  12. J jk = new K(){}; Tester.checkEqual(str(jk), "KJI", "jk");
  13. K k0 = new K(){}; Tester.checkEqual(str(k0), "KJI", "k0");
  14. }
  15. private String str(Object o) {
  16. return str(o.getClass().getInterfaces()[0]);
  17. }
  18. private String str(Class c) {
  19. String str = c.getName();
  20. Class[] is = c.getInterfaces();
  21. for (int i = 0; i < is.length; i++) {
  22. str += str(is[i]);
  23. }
  24. return str;
  25. }
  26. }
  27. interface I {}
  28. interface J {} //extends I {}
  29. interface K {} //extends J {}
  30. aspect Aspect {
  31. declare parents: J implements I;
  32. declare parents: K implements J;
  33. }