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.

OverloadedPointcutsInAspect.java 704B

1234567891011121314151617181920212223
  1. class OverloadedPointcutsInAspect {
  2. public static void main(String[] args) {
  3. new C().run();
  4. }
  5. }
  6. class C {
  7. public void run() {}
  8. }
  9. aspect A {
  10. declare parents: C implements Runnable;
  11. declare parents: C implements SubRunnable;
  12. interface SubRunnable extends Runnable {}
  13. pointcut pc(Runnable r) : target(r) && call(void run());
  14. pointcut pc(SubRunnable r) : target(r) && call(void run());
  15. before(Runnable r) : pc(r) { log("pc(Runnable r)"); }
  16. before(SubRunnable r) : pc(r) { log("pc(SubRunnable r)"); }
  17. before() : pc(Runnable) { log("pc(Runnable)"); }
  18. before() : pc(SubRunnable) { log("pc(SubRunnable)"); }
  19. before() : pc(*) { log("pc(*)"); }
  20. void log(String s) { System.out.println(s); }
  21. }