aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs/WhatsGoingOn.java
blob: 1838bc4c3a27d63fcd9f8899f602d39ea1a1c567 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
public class WhatsGoingOn {
    static public void main (String [] args) { }
}

aspect TraceClass {
    static private int level = 0;

    static private void offset() {
        for (int i = 0; i < level; ++i)  System.err.print("  ");
    }

    pointcut pc() : 
        !cflow(within(Trace*))
//        !(within(Trace*) || cflowbelow(within(Trace*)))
        ;
    before () : pc() {
        offset();
        System.err.println("-> " + thisJoinPoint);
        ++level;
    }
    after  () : pc() {
        --level;
        offset();
        System.err.println("<- " + thisJoinPoint);
    }
} 

aspect TraceTrace {

    static private int level = 0;

    static private void offset() {
        for (int i = 0; i < level; ++i)         System.err.print("  ");
    }
    
    pointcut pc() : within(TraceClass);
    before () : pc() {
        offset();
        System.err.println("=> " + thisJoinPoint);
        ++level;
    }
    after  () : pc() {
        --level;
        offset();
        System.err.println("<= " + thisJoinPoint);
    }
}

//Expected output:
//"=> staticinitialization(TraceClass.<clinit>)\n"+
//"  => set(int TraceClass.level)\n"+
//"  <= set(int TraceClass.level)\n"+
//"  => preinitialization(TraceClass())\n"+
//"  <= preinitialization(TraceClass())\n"+
//"  => initialization(TraceClass())\n"+
//"    => execution(TraceClass())\n"+
//"    <= execution(TraceClass())\n"+
//"  <= initialization(TraceClass())\n"+
//"<= staticinitialization(TraceClass.<clinit>)\n"+
//"=> execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+
//"  => call(void TraceClass.offset())\n"+
//"    => execution(void TraceClass.offset())\n"+
//"      => get(int TraceClass.level)\n"+
//"      <= get(int TraceClass.level)\n"+
//"    <= execution(void TraceClass.offset())\n"+
//"  <= call(void TraceClass.offset())\n"+
//"  => get(PrintStream java.lang.System.err)\n"+
//"  <= get(PrintStream java.lang.System.err)\n"+
//"  => call(java.lang.StringBuffer(String))\n"+
//"  <= call(java.lang.StringBuffer(String))\n"+
//"  => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  => call(String java.lang.StringBuffer.toString())\n"+
//"  <= call(String java.lang.StringBuffer.toString())\n"+
//"  => call(void java.io.PrintStream.println(String))\n"+
//"-> staticinitialization(WhatsGoingOn.<clinit>)\n"+
//"  <= call(void java.io.PrintStream.println(String))\n"+
//"  => get(int TraceClass.level)\n"+
//"  <= get(int TraceClass.level)\n"+
//"  => set(int TraceClass.level)\n"+
//"  <= set(int TraceClass.level)\n"+
//"<= execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+
//"=> execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+
//"  => get(int TraceClass.level)\n"+
//"  <= get(int TraceClass.level)\n"+
//"  => set(int TraceClass.level)\n"+
//"  <= set(int TraceClass.level)\n"+
//"  => call(void TraceClass.offset())\n"+
//"    => execution(void TraceClass.offset())\n"+
//"      => get(int TraceClass.level)\n"+
//"      <= get(int TraceClass.level)\n"+
//"    <= execution(void TraceClass.offset())\n"+
//"  <= call(void TraceClass.offset())\n"+
//"  => get(PrintStream java.lang.System.err)\n"+
//"  <= get(PrintStream java.lang.System.err)\n"+
//"  => call(java.lang.StringBuffer(String))\n"+
//"  <= call(java.lang.StringBuffer(String))\n"+
//"  => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  => call(String java.lang.StringBuffer.toString())\n"+
//"  <= call(String java.lang.StringBuffer.toString())\n"+
//"  => call(void java.io.PrintStream.println(String))\n"+
//"<- staticinitialization(WhatsGoingOn.<clinit>)\n"+
//"  <= call(void java.io.PrintStream.println(String))\n"+
//"<= execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+
//"=> execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+
//"  => call(void TraceClass.offset())\n"+
//"    => execution(void TraceClass.offset())\n"+
//"      => get(int TraceClass.level)\n"+
//"      <= get(int TraceClass.level)\n"+
//"    <= execution(void TraceClass.offset())\n"+
//"  <= call(void TraceClass.offset())\n"+
//"  => get(PrintStream java.lang.System.err)\n"+
//"  <= get(PrintStream java.lang.System.err)\n"+
//"  => call(java.lang.StringBuffer(String))\n"+
//"  <= call(java.lang.StringBuffer(String))\n"+
//"  => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  => call(String java.lang.StringBuffer.toString())\n"+
//"  <= call(String java.lang.StringBuffer.toString())\n"+
//"  => call(void java.io.PrintStream.println(String))\n"+
//"-> execution(void WhatsGoingOn.main(String[]))\n"+
//"  <= call(void java.io.PrintStream.println(String))\n"+
//"  => get(int TraceClass.level)\n"+
//"  <= get(int TraceClass.level)\n"+
//"  => set(int TraceClass.level)\n"+
//"  <= set(int TraceClass.level)\n"+
//"<= execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+
//"=> execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+
//"  => get(int TraceClass.level)\n"+
//"  <= get(int TraceClass.level)\n"+
//"  => set(int TraceClass.level)\n"+
//"  <= set(int TraceClass.level)\n"+
//"  => call(void TraceClass.offset())\n"+
//"    => execution(void TraceClass.offset())\n"+
//"      => get(int TraceClass.level)\n"+
//"      <= get(int TraceClass.level)\n"+
//"    <= execution(void TraceClass.offset())\n"+
//"  <= call(void TraceClass.offset())\n"+
//"  => get(PrintStream java.lang.System.err)\n"+
//"  <= get(PrintStream java.lang.System.err)\n"+
//"  => call(java.lang.StringBuffer(String))\n"+
//"  <= call(java.lang.StringBuffer(String))\n"+
//"  => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+
//"  => call(String java.lang.StringBuffer.toString())\n"+
//"  <= call(String java.lang.StringBuffer.toString())\n"+
//"  => call(void java.io.PrintStream.println(String))\n"+
//"<- execution(void WhatsGoingOn.main(String[]))\n"+
//"  <= call(void java.io.PrintStream.println(String))\n"+
//"<= execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n");