aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/Counting3.java
blob: 7c3486fea059198b11c7592a1d136b77a2ba857b (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Vector;
import org.aspectj.testing.*;

public class Counting3 {
    public static void main(String[] args) {
        Testing.start();
        new Counting3().f();
        Testing.finish();
    }
    int j;
    void f() {
        j = 13;
        int i = j;
    }
}

class Testing {
    static void start() {
        //                           - e main - - ca f() - - ex f() - - set j --------- - get j ---------
        Tester.expectEventsInString("e,egs,cegs,c,cgs,cegs,e,egs,cegs,s,gs,cgs,egs,cegs,g,gs,cgs,egs,cegs");
        // Tester.expectEventsInString("g,s,gs,c,e,cgs,egs,cegs");  // old, incorrect (matching dups)
    }
    static void finish() {
        Tester.checkAllEvents();
    }
}

aspect JoinPointCounting {

    pointcut g(): get(* *.*) && within(Counting3);
    before(): g() { a("g"); }

    pointcut s(): set(* *.*) && within(Counting3);
    before(): s() { a("s"); }
    
    pointcut gs(): g() || s();
    before(): gs() { a("gs"); }
    
    pointcut c(): call(* *.*(..)) && within(Counting3) && ! call(* Testing.*());
    before(): c() { a("c"); }
    pointcut e(): execution(* *.*(..)) && within(Counting3);
    before(): e() { a("e"); }

    pointcut cgs(): c() || gs(); before(): cgs() { a("cgs"); }
    pointcut egs(): e() || gs(); before(): egs() { a("egs"); }

    pointcut cegs(): c() || e() || gs(); before(): cegs() { a("cegs"); }

    static void a(String s) { Tester.event(s); }
    
}