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.

ExpandedMethodSigs.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import org.aspectj.testing.Tester;
  2. public class ExpandedMethodSigs {
  3. public static void main(String[] args) {
  4. C0 c0 = new C0();
  5. c0.mI();
  6. c0.mI1();
  7. c0.mI2();
  8. c0.mC();
  9. I1 i1 = new C0();
  10. i1.mI();
  11. i1.mI1();
  12. C1 c1 = new C1();
  13. c1.mI();
  14. c1.mC1();
  15. }
  16. }
  17. class C0 implements I1, I2 {
  18. public void mI() { System.out.println("mI"); }
  19. public void mI1() { System.out.println("mI1"); }
  20. public void mI2() { System.out.println("mI2"); }
  21. public void mC() { System.out.println("mC"); }
  22. }
  23. class C1 extends C0 {
  24. public void mC() { System.out.println("mC from C1"); }
  25. public void mC1() { System.out.println("mC1"); }
  26. }
  27. interface I1 {
  28. public void mI();
  29. public void mI1();
  30. }
  31. interface I2 {
  32. public void mI();
  33. public void mI2();
  34. }
  35. aspect A {
  36. static before(I1 i1): calls(void i1.*()) { System.out.println(">I1.* " + i1); }
  37. static before(): calls(void I2.*()) { System.out.println(">I2.*"); }
  38. static before(): calls(void C0.*()) { System.out.println(">C0.*"); }
  39. static before(): calls(void C1.*()) { System.out.println(">C1.*"); }
  40. static before(): receptions(void I1.*()) { System.out.println("-I1.*"); }
  41. static before(): receptions(void I2.*()) { System.out.println("-I2.*"); }
  42. static before(): receptions(void C0.*()) { System.out.println("-C0.*"); }
  43. static after() returning(): receptions(I1.new()) { System.out.println("-I1.new"); }
  44. static after() returning(): receptions(C0.new()) { System.out.println("-C0.new"); }
  45. static after() returning(): calls(C0, I1.new()) { System.out.println(">I1.new"); }
  46. static after() returning(): calls(C0, C0.new()) { System.out.println(">C0.new"); }
  47. }