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.

PerTargetAndVariablesWithNumbersInTheirNames.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import org.aspectj.testing.*;
  2. /**
  3. * PR#490
  4. * Came from a bug from Svan Macke:
  5. *
  6. * Here is another problem that occured when I changed
  7. * from aspectj0.8b3 to aspectj0.8b4. It seems that
  8. * (under a very special condition) aspectJ has problems
  9. * with the numbers that are appended to variable names
  10. * inside the generated advice code.
  11. *
  12. * Here is the "special condition" where the error
  13. * occured. I know the discussion about 'of eachobject'
  14. * and I also know that in the following code it is
  15. * absolutely unnecessary to use 'of eachobject' (don't
  16. * ask me why I wrote such terrible code, I do not know
  17. * it myself), but however, I think it is correct aspectj
  18. * code and should therefore compile correctly.
  19. *
  20. * @since 2000.08.06
  21. * @author Jeff Palm
  22. * @report 408
  23. */
  24. public class PerTargetAndVariablesWithNumbersInTheirNames {
  25. public static void main(String[] args) {
  26. new C();
  27. Tester.checkAllEvents();
  28. }
  29. static {
  30. Tester.expectEvent("Hello 1");
  31. Tester.expectEvent("World 2");
  32. Tester.expectEvent("Hello World around 1");
  33. Tester.expectEvent("Hello World around 2");
  34. Tester.expectEvent("Hello World around 3");
  35. Tester.expectEvent("Hello World around 4");
  36. }
  37. }
  38. class C
  39. {
  40. public C()
  41. {
  42. doSomething("Hello", "World");
  43. }
  44. public void doSomething(String arg1, String arg2)
  45. {
  46. Tester.event(arg1 + " 1");
  47. Tester.event(arg2 + " 2");
  48. }
  49. }
  50. /*
  51. * A pertarget aspect.
  52. */
  53. aspect A1 pertarget(target(C)) {
  54. void around(String arg1, String arg2):
  55. target(C) &&
  56. call(public void doSomething(String,String)) &&
  57. args(arg1, arg2) {
  58. Tester.event(arg1 + " " + arg2 + " around 1");
  59. proceed(arg1, arg2);
  60. }
  61. }
  62. /*
  63. * Another pertarget aspect.
  64. */
  65. aspect A2 pertarget(target(C)) {
  66. void around(String arg1, String arg2):
  67. target(C) &&
  68. call(public void doSomething(String,String)) &&
  69. args(arg1, arg2) {
  70. Tester.event(arg1 + " " + arg2 + " around 2");
  71. proceed(arg1, arg2);
  72. }
  73. }
  74. /*
  75. * A 'static' aspect.
  76. */
  77. aspect A3 {
  78. void around(String arg1, String arg2):
  79. target(C) &&
  80. call(public void doSomething(String,String)) &&
  81. args(arg1, arg2) {
  82. Tester.event(arg1 + " " + arg2 + " around 3");
  83. proceed(arg1, arg2);
  84. }
  85. }
  86. /*
  87. * Another 'static' aspect.
  88. */
  89. aspect A4 {
  90. void around(String arg1, String arg2):
  91. target(C) &&
  92. call(public void doSomething(String,String)) &&
  93. args(arg1, arg2) {
  94. Tester.event(arg1 + " " + arg2 + " around 4");
  95. proceed(arg1, arg2);
  96. }
  97. }