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
|
import org.aspectj.testing.Tester;
import org.aspectj.lang.*;
import org.aspectj.lang.reflect.*;
/** @testcase PR#764 binding handler args with indeterminate prefix and suffix */
public class IndeterminateHandlerArg {
public static void main (String[] args) {
Throwable throwable = new Throwable("throwable");
Error error = new Error("error");
RuntimeException runtime = new RuntimeException("runtime") {
RuntimeException f() { return this; }
}.f();
try { throw error; }
catch (Error e) { A.event(e.getMessage()); }
try { throw throwable; }
catch (Throwable e) { A.event(e.getMessage()); }
try { throw error; }
catch (Throwable e) { A.event(e.getMessage()); }
try { throw runtime; }
catch (Throwable e) { A.event(e.getMessage()); }
try { throw runtime; }
catch (RuntimeException e) { A.event(e.getMessage()); }
Tester.checkEventsFromFile("IndeterminateHandlerArg.events");
}
}
aspect A {
void e(String label, JoinPoint jp) {
e(label, jp, (Throwable) jp.getArgs()[0]);
}
void e(String label, JoinPoint jp, Throwable t) {
String m = jp.toLongString()
+ ": " + t.getClass().getName()
+ " - " + t.getMessage()
+ " @ " + label;
event(m);
}
static void event(String m) {
Tester.event(m);
}
pointcut hd() : withincode(static void main(..)) && handler(*);
before (Throwable t) : hd() && args(t) { e("before Throwable", thisJoinPoint, t); }
before (Error t) : hd() && args(t) { e("before Error", thisJoinPoint, t); }
before () : hd() && args(Throwable) { e("before args(Throwable)", thisJoinPoint); }
before () : hd() && args(Error) { e("before args(Error)", thisJoinPoint); }
before () : hd() && args(Throwable,..) { e("before args(Throwable,..)", thisJoinPoint); }
before () : hd() && args(..,Throwable) { e("before args(..,Throwable)", thisJoinPoint); }
before () : hd() && args(Error,..) { e("before args(Error,..)", thisJoinPoint); }
before () : hd() && args(..,Error) { e("before args(..,Error)", thisJoinPoint); }
before (Throwable t) : hd() && args(t,..) { e("before Throwable,..", thisJoinPoint, t); }
before (Error t) : hd() && args(t,..) { e("before Error,..", thisJoinPoint, t); }
before (Throwable t) : hd() && args(..,t) { e("before ..,Throwable", thisJoinPoint, t); }
before (Error t) : hd() && args(..,t) { e("before ..,Error", thisJoinPoint, t); }
before () : hd() && args(Throwable,*) { Tester.check(false, "args(Throwable,*)"); }
before () : hd() && args(*,Throwable) { Tester.check(false, "args(*,Throwable)"); }
before () : hd() && args(Error,*) { Tester.check(false, "args(Error,*)"); }
before () : hd() && args(*,Error) { Tester.check(false, "args(*,Error)"); }
before (Throwable t) : hd() && args(t,*) { Tester.check(false, "args((Throwable)t,*)"); }
before (Error t) : hd() && args(t,*) { Tester.check(false, "args((Error)t,*)"); }
before (Throwable t) : hd() && args(*,t) { Tester.check(false, "args(*,(Throwable)t)"); }
before (Error t) : hd() && args(*,t) { Tester.check(false, "args(*,(Error)t)"); }
}
|