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.

NonAlphaSignaturePatternCE.java 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import org.aspectj.testing.Tester;
  2. //PR#493
  3. public class NonAlphaSignaturePatternCE {
  4. public static void main(String[] args) {
  5. C1 c = new C1();
  6. c.m1();
  7. c.update();
  8. Tester.checkAllEventsIgnoreDups();
  9. }
  10. }
  11. class C1 {
  12. public int fi1;
  13. public float f1 = 1.f;
  14. void cflowbelow() { } // cflowbelow join points; also test keyword collision
  15. void m1() { String s = ("m1 "); cflowbelow(); }
  16. void update() {
  17. fi1 = 1; // set join point
  18. int i = fi1; // get join point
  19. }
  20. }
  21. // PR#493 Signature patterns without leading alphabetic characters
  22. aspect A {
  23. static {
  24. // expect all of these messages when test runs
  25. Tester.expectEvent("call m1");
  26. Tester.expectEvent("before call *1");
  27. Tester.expectEvent("before p1");
  28. Tester.expectEvent("before execution *1");
  29. Tester.expectEvent("initialization *1");
  30. Tester.expectEvent("staticinitialization *1");
  31. Tester.expectEvent("withincode *1");
  32. Tester.expectEvent("cflow *1");
  33. Tester.expectEvent("cflowbelow *1");
  34. Tester.expectEvent("set *1");
  35. Tester.expectEvent("get *1");
  36. }
  37. after () : call(void m1()) { Tester.event("call m1"); } // normal case
  38. // @testTarget signature.patterns.leadingnumeric.pointcut
  39. pointcut p1(): call(void *1()) ; // incorrect compiler error here PR#493
  40. before () : p1(){ // incorrect compiler error here PR#493
  41. Tester.event("before p1");
  42. }
  43. // @testTarget signature.patterns.leadingnumeric.anonpointcut.call
  44. before () : call(void *1()) { // incorrect compiler error here PR#493
  45. Tester.event("before call *1");
  46. }
  47. // @testTarget signature.patterns.leadingnumeric.anonpointcut.execution
  48. after () : execution(void *1()) {// incorrect compiler error here PR#493
  49. Tester.event("before execution *1");
  50. }
  51. // @testTarget signature.patterns.leadingnumeric.anonpointcut.initialization
  52. after () : initialization(*1.new()) {// incorrect compiler error here PR#493
  53. Tester.event("initialization *1");
  54. }
  55. // @testTarget signature.patterns.leadingnumeric.anonpointcut.staticinitialization
  56. before () : staticinitialization(*1) {// incorrect compiler error here PR#493
  57. Tester.event("staticinitialization *1");
  58. }
  59. // @testTarget signature.patterns.leadingnumeric.anonpointcut.withincode
  60. before () : withincode(void C1.*1()) {// incorrect compiler error here PR#493
  61. Tester.event("withincode *1");
  62. }
  63. // @testTarget signature.patterns.leadingnumeric.anonpointcut.set
  64. before () : set(int C*1.fi1) {// incorrect compiler error here PR#493
  65. Tester.event("set *1");
  66. }
  67. // @testTarget signature.patterns.leadingnumeric.anonpointcut.get
  68. before () : get(int *.*1) {// incorrect compiler error here PR#493
  69. Tester.event("get *1");
  70. }
  71. // @testTarget signature.patterns.leadingnumeric.anonpointcut.set
  72. }
  73. /**
  74. * Moved advice on cflow to B in order to continue testing this
  75. * as well as possible without forcing a StackOverflowError
  76. */
  77. aspect B {
  78. // @testTarget signature.patterns.leadingnumeric.anonpointcut.cflowbelow
  79. before () : cflowbelow(execution(void *1.m1())) && !within(B) {
  80. Tester.event("cflowbelow *1");
  81. }
  82. // @testTarget signature.patterns.leadingnumeric.anonpointcut.cflow
  83. before () : cflow(execution(void *1.m1())) && !within(B) {
  84. Tester.event("cflow *1");
  85. }
  86. }