summaryrefslogtreecommitdiffstats
path: root/tests/base/test124/Driver.java
blob: 3c9e058b37e2fe04458836371d4b33764bd22cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import org.aspectj.testing.Tester;

public class Driver {
  public static void main(String[] args) { test(); }
  
  public static void test() {
    Driver.m(4);
    Tester.checkEqual(Trace.enterCount, 2, "befores");
    // The after for this method hasn't been run yet
    Tester.checkEqual(Trace.exitCount, 1, "afters");
  }

  static int m(int x) {
    return 0;
  }
}

aspect Trace {
    public static int enterCount, exitCount;
    // notice the absence of any modifiers in the advise
     before(): within(Driver) && (execution(void test()) || 
                                       execution(* m(..))) {
        enterCount++;
    }
     after(): within(Driver) && (execution(void test()) ||
                                      execution(* m(..))) {
        exitCount++;
    }
}