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.

Cricket.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import org.aspectj.testing.Tester;
  2. public class Cricket {
  3. public static void main(String[] args) {
  4. Lib l = new Lib();
  5. Tester.event("call stringMethod");
  6. l.stringMethod(2);
  7. Tester.event("call voidMethod");
  8. l.voidMethod(2);
  9. Tester.checkEventsFromFile("Cricket.out");
  10. }
  11. }
  12. class Lib {
  13. public void voidMethod(int count) {
  14. if (count == 0) return;
  15. else voidMethod(count - 1);
  16. }
  17. public String stringMethod(int count) {
  18. if (count == 0) return "0";
  19. else return count + "-" + stringMethod(count-1);
  20. }
  21. }
  22. aspect Trace {
  23. pointcut entry(): target(Lib) && call(* *(..));
  24. pointcut topEntry(): entry() && !cflowbelow(entry());
  25. before(): topEntry() {
  26. Tester.event("->top entry: " + thisJoinPoint);
  27. }
  28. after(): entry() {
  29. Tester.event("->exit: " + thisJoinPoint);
  30. }
  31. after() returning (Object o): entry() {
  32. Tester.event("->exit: " + thisJoinPoint + " with " + o);
  33. }
  34. after(): topEntry() {
  35. Tester.event("->top exit: " + thisJoinPoint);
  36. }
  37. after() returning (Object o): topEntry() {
  38. Tester.event("->top exit: " + thisJoinPoint + " with " + o);
  39. }
  40. }