summaryrefslogtreecommitdiffstats
path: root/weaver/testsrc/Aspect.java
blob: bdb8108f4bd82c1d3be9416c391bbf912bd2eb84 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/* This file is part of the compiler and core tools for the AspectJ(tm)
 * programming language; see http://aspectj.org
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is AspectJ.
 *
 * The Initial Developer of the Original Code is Palo Alto Research Center,
 * Incorporated (PARC). Portions created by PARC are are
 * Copyright (C) 2002 Palo Alto Research Center, Incorporated.
 * All Rights Reserved.
 *
 * Contributor(s):
 */

import java.util.*;

import org.aspectj.runtime.internal.*;
import org.aspectj.runtime.internal.AroundClosure;
import org.aspectj.lang.JoinPoint;

public class Aspect {

	public static void ajc_before_0() {
		System.out.println("before_0");		
	}
 	public static void ajc_before_0(String s) {
		System.out.println("before_0: " + s);		
	}
    public static boolean ajc_around_0(ArrayList s, AroundClosure c) throws Throwable {
        System.out.println("doing around, got " + s);
        Object ret = c.run(new Object[] {s}); // proceed(s)
        return ((Boolean) ret).booleanValue();   
    }

	public static void ajc_before_0(java.util.ArrayList list) {
		System.out.println("before_0: " + list);		
	}

	public static void ajc_before_method_execution() {

	}	
	public static void ajc_before_method_execution(Object o) {
		System.out.println("before_method_execution: " + o);
	}

    public static void ajc_after_method_execution() {
        System.out.println("after_method_execution");
    }    
    public static void ajc_after_method_execution(Object o) {
        System.out.println("after_method_execution: " + o);
    }
    
    public static void ajc_afterReturning_method_execution() {
        System.out.println("ajc_afterReturning_method_execution");
    }           	
	public static void ajc_afterReturning_method_execution(Object o) {
		System.out.println("afterReturning_method_execution: " + o);
	}

    public static void ajc_afterThrowing_method_execution() {
        System.out.println("ajc_afterThrowing_method_execution");
    }               
    public static void ajc_afterThrowing_method_execution(Object o) {
        System.out.println("afterThrowing_method_execution: " + o);
    }    




        
    public static Object ajc_around(AroundClosure closure) throws Throwable {
        Object ret = closure.run(new Object[] {});
        return ret;
    }   
    
    public static Object ajc_around(AroundClosure closure, JoinPoint tjp) throws Throwable {
        System.out.println("thisJoinPoint: " + tjp);
        Object ret = closure.run(new Object[] {});
        return ret;
    }   
    
    // ---    
    
    
    public static void ajc_before_method_call() {
        System.out.println("before_method_call");
    }    
    public static void ajc_before_method_call(Object o) {
        System.out.println("before_method_call: " + o);
    }
        
    public static void ajc_after_method_call() {
        System.out.println("after_method_call");
    }    
    public static void ajc_after_method_call(Object o) {
        System.out.println("after_method_call: " + o);
    }       
	
    public static void ajc_afterReturning_method_call() {
        System.out.println("ajc_afterReturning_method_call");
    }
	public static void ajc_afterReturning_method_call(Object o) {
		System.out.println("afterReturning_method_call: " + o);
	}
	
    public static void ajc_afterThrowing_method_call() {
        System.out.println("ajc_afterThrowing_method_call");
    }
    public static void ajc_afterThrowing_method_call(Object o) {
        System.out.println("afterThrowing_method_call: " + o);
    }    
    
    public static Object ajc_around_method_call(AroundClosure closure) throws Throwable {
        Object ret = null;
        for (int i=0; i<3; i++) {
            System.out.println("enter: " + i);
            ret = closure.run(new Object[] {});
        }
        return ret;
    }
    
    // ----

    public static void ajc_before_constructor_call() {
        System.out.println("before_constructor_call");
    }    
    public static void ajc_before_constructor_call(Object o) {
        System.out.println("before_constructor_call: " + o);
    }
        
    public static void ajc_after_constructor_call() {
        System.out.println("after_constructor_call");
    }    
    public static void ajc_after_constructor_call(Object o) {
        System.out.println("after_constructor_call: " + o);
    }       
	
    public static void ajc_afterReturning_constructor_call() {
        System.out.println("ajc_afterReturning_constructor_call");
    }
	public static void ajc_afterReturning_constructor_call(Object o) {
		System.out.println("afterReturning_constructor_call: " + o);
	}
	
    public static void ajc_afterThrowing_constructor_call() {
        System.out.println("ajc_afterThrowing_constructor_call");
    }
    public static void ajc_afterThrowing_constructor_call(Object o) {
        System.out.println("afterThrowing_constructor_call: " + o);
    }    
    
    public static Object ajc_around_constructor_call(AroundClosure closure) throws Throwable {
        Object ret = null;
        for (int i=0; i<3; i++) {
            System.out.println("enter: " + i);
            ret = closure.run(new Object[] {});
        }
        return ret;
    }    
    // ----

    public static void ajc_before_constructor_execution() {
        System.out.println("before_constructor_execution");
    }    
    public static void ajc_before_constructor_execution(Object o) {
        System.out.println("before_constructor_execution: " + o);
    }
        
    public static void ajc_after_constructor_execution() {
        System.out.println("after_constructor_execution");
    }    
    public static void ajc_after_constructor_execution(Object o) {
        System.out.println("after_constructor_execution: " + o);
    }       
	
    public static void ajc_afterReturning_constructor_execution() {
        System.out.println("ajc_afterReturning_constructor_execution");
    }
	public static void ajc_afterReturning_constructor_execution(Object o) {
		System.out.println("afterReturning_constructor_execution: " + o);
	}
	
    public static void ajc_afterThrowing_constructor_execution() {
        System.out.println("ajc_afterThrowing_constructor_execution");
    }
    public static void ajc_afterThrowing_constructor_execution(Object o) {
        System.out.println("afterThrowing_constructor_execution: " + o);
    }    
    
    public static Object ajc_around_constructor_execution(AroundClosure closure) throws Throwable {
        Object ret = null;
        for (int i=0; i<3; i++) {
            System.out.println("enter: " + i);
            ret = closure.run(new Object[] {});
        }
        return ret;
    }    
    
    
    // ---

	
	public static void ajc_before_field_get() {
		System.out.println("before_field_get");
	}   
    public static void ajc_before_field_get(Object o) {
        System.out.println("before_field_get: " + o);
    }
    
    public static void ajc_after_field_get() {
        System.out.println("after_field_get");
    }    
    public static void ajc_after_field_get(Object o) {
        System.out.println("after_field_get: " + o);
    }
    
    public static void ajc_afterReturning_field_get() {
        System.out.println("afterReturning_field_get");
    }    
    public static void ajc_afterReturning_field_get(Object o) {
        System.out.println("afterReturning_field_get: " + o);
    }

    public static void ajc_afterThrowing_field_get() {
        System.out.println("afterThrowing_field_get");
    }    
    public static void ajc_afterThrowing_field_get(Object o) {
        System.out.println("afterThrowing_field_get: " + o);
    }
    public static void ajc_afterThrowing_field_get(Throwable t) {
        System.out.println("afterThrowing_field_get: " + t);
    }

	public static Object ajc_around_field_get(AroundClosure closure) throws Throwable {
		Object ret = closure.run(new Object[] {});
		return ret;
	}
	
   
    // ---

	
	public static void ajc_before_field_set() {
		System.out.println("before_field_set");
	}   
    public static void ajc_before_field_set(Object o) {
        System.out.println("before_field_set: " + o);
    }
    
    public static void ajc_after_field_set() {
        System.out.println("after_field_set");
    }    
    public static void ajc_after_field_set(Object o) {
        System.out.println("after_field_set: " + o);
    }
    
    public static void ajc_afterReturning_field_set() {
        System.out.println("afterReturning_field_set");
    }    
    public static void ajc_afterReturning_field_set(Object o) {
        System.out.println("afterReturning_field_set: " + o);
    }

    public static void ajc_afterThrowing_field_set() {
        System.out.println("afterThrowing_field_set");
    }    
    public static void ajc_afterThrowing_field_set(Object o) {
        System.out.println("afterThrowing_field_set: " + o);
    }
    public static void ajc_afterThrowing_field_set(Throwable t) {
        System.out.println("afterThrowing_field_set: " + t);
    }

	public static Object ajc_around_field_set(AroundClosure closure) throws Throwable {
		Object ret = closure.run(new Object[] {});
		return ret;
	}	
	
	// don't call this method for callee-side call join points
	public static void ajc_before(JoinPoint.StaticPart tjp) {
		System.out.println("before: " + tjp);
		if (tjp.getSourceLocation() == null) {
			throw new RuntimeException("didn't want null");
		}
		System.out.println("   loc: " + tjp.getSourceLocation());
	}
	
	public static void ajc_before(JoinPoint tjp) {
		System.out.println("before: " + tjp + " this = " + tjp.getThis() + 
				" target = " + tjp.getTarget() +
				" args = " + Arrays.asList(tjp.getArgs()));
	}
	
	// per object stuff
	
	private static Map objects = new HashMap();
	
	public static void ajc$perObjectBind(Object o) {
		if (objects.containsKey(o)) return;
		objects.put(o, new Aspect());
	}
	
	public static boolean hasAspect(Object o) {
		return objects.containsKey(o);
	}
	
	public static Aspect aspectOf(Object o) {
		return (Aspect) objects.get(o);
	}	
	
	
	// per cflow stuff
	
	public static void ajc$perCflowPush() {
		ajc$perCflowStack.pushInstance(new Aspect());
	}
	
	public static boolean hasAspect() {
		return ajc$perCflowStack.isValid();
	}
	
	public static Aspect aspectOf() {
		return (Aspect) ajc$perCflowStack.peekInstance();
	}
	
	public static CFlowStack ajc$perCflowStack = new CFlowStack();
	
	// non-static methods
	
	public static Aspect ajc$perSingletonInstance = new Aspect();
	public void ajc_before() {
		System.out.println("before in: " + this);
	}
	
    public static CFlowStack ajc$cflowStack$0 = new CFlowStack();
	
	
}