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.

Counting3.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import java.util.Vector;
  2. import org.aspectj.testing.*;
  3. public class Counting3 {
  4. public static void main(String[] args) {
  5. Testing.start();
  6. new Counting3().f();
  7. Testing.finish();
  8. }
  9. int j;
  10. void f() {
  11. j = 13;
  12. int i = j;
  13. }
  14. }
  15. class Testing {
  16. static void start() {
  17. // - e main - - ca f() - - ex f() - - set j --------- - get j ---------
  18. Tester.expectEventsInString("e,egs,cegs,c,cgs,cegs,e,egs,cegs,s,gs,cgs,egs,cegs,g,gs,cgs,egs,cegs");
  19. // Tester.expectEventsInString("g,s,gs,c,e,cgs,egs,cegs"); // old, incorrect (matching dups)
  20. }
  21. static void finish() {
  22. Tester.checkAllEvents();
  23. }
  24. }
  25. aspect JoinPointCounting {
  26. pointcut g(): get(* *.*) && within(Counting3);
  27. before(): g() { a("g"); }
  28. pointcut s(): set(* *.*) && within(Counting3);
  29. before(): s() { a("s"); }
  30. pointcut gs(): g() || s();
  31. before(): gs() { a("gs"); }
  32. pointcut c(): call(* *.*(..)) && within(Counting3) && ! call(* Testing.*());
  33. before(): c() { a("c"); }
  34. pointcut e(): execution(* *.*(..)) && within(Counting3);
  35. before(): e() { a("e"); }
  36. pointcut cgs(): c() || gs(); before(): cgs() { a("cgs"); }
  37. pointcut egs(): e() || gs(); before(): egs() { a("egs"); }
  38. pointcut cegs(): c() || e() || gs(); before(): cegs() { a("cegs"); }
  39. static void a(String s) { Tester.event(s); }
  40. }