blob: d6ba60bdcfd755bfbd7bf3312ff5ebff8c4f4448 (
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
|
import org.aspectj.testing.Tester;
public class AfterReturningHandler {
public static void main(String[] args) {
AfterReturningHandler p = new AfterReturningHandler();
p.mIntThrowing();
Tester.checkAndClearEvents(new String[] {"returned null" }); // will probably say "returned null" for all below
p.mVoidThrowing();
Tester.checkAndClearEvents(new String[] { });
p.mIntThrowingReturning();
Tester.checkAndClearEvents(new String[] { });
p.mVoidThrowingReturning();
Tester.checkAndClearEvents(new String[] { });
}
public void mVoidThrowing() {
try { throw new RuntimeException(); }
catch (RuntimeException e) {
}
}
public int mIntThrowing() {
try { throw new RuntimeException(); }
catch (RuntimeException e) {
}
return 3;
}
public void mVoidThrowingReturning() {
try { throw new RuntimeException(); }
catch (RuntimeException e) {
return;
}
}
public int mIntThrowingReturning() {
try { if (true) throw new RuntimeException(); }
catch (RuntimeException e) {
return 3;
}
return 999999;
}
AfterReturningHandler() {
}
}
aspect A {
private void callEvent(String s, Object o) {
Tester.event(s + " " + o);
}
after() returning (Object o) : handler(RuntimeException) {
callEvent("returned ", o);
}
}
|