aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AJDBClass.java
blob: 7dd1b3e24c5d0a94740739450aa43affcc062fbb (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
public class AJDBClass {

    public      int publicInt = 0;
    protected   int protectedInt = 1;
    private     int privateInt = 2;
    /*package*/ int packageInt = 3;

    public       AJDBClass()         {}
    /*package*/  AJDBClass(int i)    {}
    protected    AJDBClass(byte b)   {}
    private      AJDBClass(String s) {}

    {
        publicInt = 13;
    }
    
    public static void main(String[] args) {
        System.out.println("Starting...");
        new AJDBClass().go();
        System.out.println("Done.");
    }

    void go() {
        int j = 1;
        String string = "string";
        byte b = (byte)9;
        long l = 123123123;
        double d = 123.123;
        short s = (short)4;
        char c = 'c';
        Object o = null;
        Integer integer = new Integer(13);
        a();
        b();
        c();
        d();
    }

    public void a() {
        System.out.println("a");
    }
    
    protected void b() {
        System.out.println("b");
    }

    private void c() {
        System.out.println("c");
    }

    void d() {
        System.out.println("d");
    }
}

aspect Aspect {
    pointcut ours():          instanceof(AJDBClass);
    pointcut allReceptions(): receptions(void *(..)) && ours();
    pointcut allExecutions(): executions(void *(..)) && within(AJDBClass);
    pointcut allCalls():      calls(void AJDBClass.*(..));
    pointcut allCallsTo():    callsto(receptions(void *(..)) && instanceof(AJDBClass));

    static before(): allReceptions() {
        System.out.println("before receptions: " + thisJoinPoint);
    }
    static after():  allReceptions() {
        System.out.println("after receptions: " + thisJoinPoint);
    }
    static around() returns void: allReceptions() {
        System.out.println("around before receptions: " + thisJoinPoint);
        proceed();
        System.out.println("around after receptions: " + thisJoinPoint);
    }

    static before(): allExecutions() {
        System.out.println("before executions: " + thisJoinPoint);
    }
    static after():  allExecutions() {
        System.out.println("after executions: " + thisJoinPoint);
    }
    static around() returns void: allExecutions() {
        System.out.println("around before executions: " + thisJoinPoint);
        proceed();
        System.out.println("around after executions: " + thisJoinPoint);
    }

    static before(): allCalls() {
        System.out.println("before calls: " + thisJoinPoint);
    }
    static after():  allCalls() {
        System.out.println("after calls: " + thisJoinPoint);
    }
    static around() returns void: allCalls() {
        System.out.println("around before calls: " + thisJoinPoint);
        proceed();
        System.out.println("around after calls: " + thisJoinPoint);
    }

    static before(): allCallsTo() {
        System.out.println("before callsTo: " + thisJoinPoint);
    }
    static after():  allCallsTo() {
        System.out.println("after callsTo: " + thisJoinPoint);
    }
    static around() returns void: allCallsTo() {
        System.out.println("around before callsTo: " + thisJoinPoint);
        proceed();
        System.out.println("around after callsTo: " + thisJoinPoint);
    }        
}