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.

ExpandedDotDotPattern.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import org.aspectj.testing.Tester;
  2. public class ExpandedDotDotPattern {
  3. public static void main(String[] args) {
  4. new A().foo();
  5. new B().foo(3);
  6. new C().foo(3, 3);
  7. new D().foo(3, 3, 3);
  8. new E().foo(3, 3, 3, 3);
  9. new F().foo(3, 3, 3, 3, 3);
  10. Tester.checkEqual(A.count, 1 + 1 + 1 + 1 + 1, "not enough 0-ary");
  11. Tester.checkEqual(B.count, 0 + 2 + 3 + 4 + 5, "not enough 1-ary");
  12. Tester.checkEqual(C.count, 0 + 1 + 4 + 7 + 11, "not enough 2-ary");
  13. Tester.checkEqual(D.count, 0 + 1 + 3 + 8 + 15, "not enough 3-ary");
  14. Tester.checkEqual(E.count, 0 + 1 + 3 + 7 + 16, "not enough 4-ary");
  15. Tester.checkEqual(F.count, 0 + 1 + 3 + 7 + 15, "not enough 5-ary");
  16. }
  17. }
  18. interface I {
  19. void inc();
  20. }
  21. class A implements I {
  22. static int count = 0;
  23. public void inc() { count++; }
  24. void foo() {}
  25. }
  26. class B implements I {
  27. static int count = 0;
  28. public void inc() { count++; }
  29. void foo(int a) {}
  30. }
  31. class C implements I {
  32. static int count = 0;
  33. public void inc() { count++; }
  34. void foo(int a, int b) {}
  35. }
  36. class D implements I {
  37. static int count = 0;
  38. public void inc() { count++; }
  39. void foo(int a, int b, int c) {}
  40. }
  41. class E implements I {
  42. static int count = 0;
  43. public void inc() { count++; }
  44. void foo(int a, int b, int c, int d) {}
  45. }
  46. class F implements I {
  47. static int count = 0;
  48. public void inc() { count++; }
  49. void foo(int a, int b, int c, int d, int e) {}
  50. }
  51. aspect Aspect {
  52. // zero
  53. before(I i): this(i) && execution(void foo()) {
  54. System.out.println(thisJoinPoint);
  55. i.inc();
  56. }
  57. // one
  58. before(I i): this(i) && execution(void foo( ..)) { i.inc(); }
  59. before(I i): this(i) && execution(void foo(int)) {
  60. System.out.println("(int)" + thisJoinPoint);
  61. i.inc();
  62. }
  63. // two
  64. before(I i): this(i) && execution(void foo( .., ..)) {
  65. System.out.println("(.., ..)" + thisJoinPoint);
  66. i.inc();
  67. }
  68. before(I i): this(i) && execution(void foo(int, ..)) { i.inc(); }
  69. before(I i): this(i) && execution(void foo( .., int)) {
  70. System.out.println("(.., int)" + thisJoinPoint);
  71. i.inc();
  72. }
  73. before(I i): this(i) && execution(void foo(int, int)) { i.inc(); }
  74. // three
  75. before(I i): this(i) && execution(void foo( .., .., ..)) { i.inc(); }
  76. before(I i): this(i) && execution(void foo( .., .., int)) { i.inc(); }
  77. before(I i): this(i) && execution(void foo( .., int, ..)) { i.inc(); }
  78. before(I i): this(i) && execution(void foo( .., int, int)) { i.inc(); }
  79. before(I i): this(i) && execution(void foo(int, .., ..)) { i.inc(); }
  80. before(I i): this(i) && execution(void foo(int, .., int)) { i.inc(); }
  81. before(I i): this(i) && execution(void foo(int, int, ..)) { i.inc(); }
  82. before(I i): this(i) && execution(void foo(int, int, int)) { i.inc(); }
  83. // four
  84. before(I i): this(i) && execution(void foo( .., .., .., ..)) { i.inc(); }
  85. before(I i): this(i) && execution(void foo( .., .., .., int)) { i.inc(); }
  86. before(I i): this(i) && execution(void foo( .., .., int, ..)) { i.inc(); }
  87. before(I i): this(i) && execution(void foo( .., .., int, int)) { i.inc(); }
  88. before(I i): this(i) && execution(void foo( .., int, .., ..)) { i.inc(); }
  89. before(I i): this(i) && execution(void foo( .., int, .., int)) { i.inc(); }
  90. before(I i): this(i) && execution(void foo( .., int, int, ..)) { i.inc(); }
  91. before(I i): this(i) && execution(void foo( .., int, int, int)) { i.inc(); }
  92. before(I i): this(i) && execution(void foo(int, .., .., ..)) { i.inc(); }
  93. before(I i): this(i) && execution(void foo(int, .., .., int)) { i.inc(); }
  94. before(I i): this(i) && execution(void foo(int, .., int, ..)) { i.inc(); }
  95. before(I i): this(i) && execution(void foo(int, .., int, int)) { i.inc(); }
  96. before(I i): this(i) && execution(void foo(int, int, .., ..)) { i.inc(); }
  97. before(I i): this(i) && execution(void foo(int, int, .., int)) { i.inc(); }
  98. before(I i): this(i) && execution(void foo(int, int, int, ..)) { i.inc(); }
  99. before(I i): this(i) && execution(void foo(int, int, int, int)) { i.inc(); }
  100. }