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.

HasMethodMatching.aj 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import java.io.*;
  2. // Should match as indicated
  3. public aspect HasMethodMatching {
  4. declare parents: hasmethod(* a(@Anno1 *)) implements Serializable; // yes Target1
  5. declare parents: hasmethod(* b(@Anno1 *)) implements Serializable; // no
  6. declare parents: hasmethod(* c(@Anno1 (*))) implements Serializable; // yes Target3
  7. declare parents: hasmethod(* d(@Anno1 (@Anno2 *))) implements Serializable; // yes Target4
  8. declare parents: hasmethod(* e(@Anno1 (@Anno2 *))) implements Serializable; // no
  9. public static void main(String []argv) {
  10. System.out.println("Target1? "+(new Target1() instanceof Serializable));
  11. System.out.println("Target2? "+(new Target2() instanceof Serializable));
  12. System.out.println("Target3? "+(new Target3() instanceof Serializable));
  13. System.out.println("Target4? "+(new Target4() instanceof Serializable));
  14. System.out.println("Target5? "+(new Target5() instanceof Serializable));
  15. }
  16. }
  17. class Target1 {
  18. public void a(AnnotatedWithAnno1 p) {}
  19. }
  20. class Target2 {
  21. public void b(@Anno1 String p) {}
  22. }
  23. class Target3 {
  24. public void c(@Anno1 String p) {}
  25. }
  26. class Target4 {
  27. public void d(@Anno1 AnnotatedWithAnno2 p) {}
  28. }
  29. class Target5 {
  30. public void e(@Anno1 AnnotatedWithAnno1 p) {}
  31. }