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.

PR353e.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. public class PR353e {
  2. public static void main(String[] args){
  3. new PR353e().go();
  4. }
  5. void go(){
  6. C c;
  7. // System.out.println("\nwith C...");
  8. // c = new C();
  9. // c.foo(this);
  10. // c.bar(this);
  11. // System.out.println("\nwith D...");
  12. // c = new D();
  13. // c.foo(this);
  14. // c.bar(this);
  15. // System.out.println("\nwith CE...");
  16. // c = new E();
  17. // c.foo(this);
  18. System.out.println("\nwith E...");
  19. E e = new E();
  20. e.foo(this);
  21. System.out.println("\nwith E2...");
  22. E2 e2 = new E2();
  23. e2.foo(this);
  24. e2.bar(this);
  25. }
  26. }
  27. interface I { }
  28. class C{
  29. void foo(PR353e a){ System.out.println("foo"); }
  30. }
  31. class E extends C implements I { }
  32. class E2 extends C implements I { void foo(PR353e a) { System.out.println("foo2"); } }
  33. aspect A {
  34. pointcut p(C c): receptions(* *(PR353e)) && instanceof(c) && !instanceof(E);
  35. static before(C c): p(c) {
  36. System.out.println("1 before A " + thisJoinPoint.methodName + " with:" + c + ":" + thisJoinPoint.className);
  37. }
  38. pointcut p3(): receptions(* *(PR353e)) && !instanceof(E);
  39. static before(): p3() {
  40. System.out.println("3 before A " + thisJoinPoint.methodName + " with:" + thisJoinPoint.className);
  41. }
  42. pointcut p4(): receptions(* *(PR353e)) && !instanceof(E2);
  43. static before(): p4() {
  44. System.out.println("4 before A " + thisJoinPoint.methodName + " with:" + thisJoinPoint.className);
  45. }
  46. }
  47. aspect B {
  48. pointcut p(C c): receptions(* *(PR353e)) && instanceof(c) && !instanceof(E);
  49. static before(C c): p(c) {
  50. System.out.println("1 before B " + thisJoinPoint.methodName + " with:" + c + ":" + thisJoinPoint.className);
  51. }
  52. pointcut p3(): receptions(* *(PR353e)) && !instanceof(E);
  53. static before(): p3() {
  54. System.out.println("3 before B " + thisJoinPoint.methodName + " with:" + thisJoinPoint.className);
  55. }
  56. }