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.

pr100195.aj 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import org.aspectj.testing.Tester;
  2. public class pr100195 {
  3. public static void main(String[] args) {
  4. new Foo().foo();
  5. AroundCasting.main(new String[0]);
  6. }
  7. }
  8. class Foo {
  9. static int x;
  10. private String myString = "A String";
  11. public static void main(String[] args) {
  12. new Foo().foo();
  13. AroundCasting.main(new String[0]);
  14. }
  15. public void foo() {
  16. String myLocal = myString;
  17. x = 5;
  18. System.out.println(myLocal); // breakpoint here
  19. bar(x);
  20. }
  21. public void bar(int y) {}
  22. }
  23. // Test.aj
  24. aspect Test {
  25. void around() : ( execution(* Foo.foo(..) ) ) {
  26. int y = 4;
  27. System.out.println("before");
  28. proceed();
  29. System.out.println("after");
  30. }
  31. }
  32. class AroundCasting {
  33. public static void main(String[] args) {
  34. bar(x);
  35. //Tester.checkEqual(x, 1003);
  36. }
  37. static int x;
  38. static void bar(int y) {}
  39. }
  40. aspect A {
  41. static boolean test() { return true; }
  42. int around(): if (test()) && get(int AroundCasting.x) {
  43. return proceed() + 1000;
  44. }
  45. void around(): execution(void AroundCasting.main(String[])) {
  46. Tester.event("enter main");
  47. proceed();
  48. }
  49. }