blob: e74ffe9e5ab494d7750ef77f1e6cc77957043412 (
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
|
import org.aspectj.testing.Tester;
aspect Test {
public static boolean invariant() { return true ; }
after() returning : call(static void AssertInAdviceBug.call() ) {
assert !invariant() ;
}
void around(): call(static void call1()) {
assert !invariant();
}
static void AssertInAdviceBug.call2() {
assert !invariant();
}
}
/** @testcase PR#657 PUREJAVA assert statement in advice [requires 1.4] */
public class AssertInAdviceBug {
private static boolean useJavacMode = false;
public static void main(String[] args) {
AssertInAdviceBug.class.getClassLoader().setClassAssertionStatus("Test", true);
AssertInAdviceBug.class.getClassLoader().setClassAssertionStatus("AssertInAdviceBug", false);
boolean gotAssert = false;
try {
call();
} catch (AssertionError e) {
gotAssert = true;
StackTraceElement[] stack = e.getStackTrace();
// this test should only run when we're not in -usejavac mode
if (stack[0].getFileName().endsWith("AssertInAdviceBug.java")) {
Tester.checkEqual(stack[0].getLineNumber(), 6, "bad line for assert");
} else {
useJavacMode = true;
System.err.println("!!!!!!!!!!!!!!!!!!!!!!!IN JAVAC MODE!!!!!!!!!!!!!!!!!!!!1");
}
}
Tester.check(gotAssert, "no assert");
gotAssert = false;
try {
call1();
} catch (AssertionError e) {
gotAssert = true;
StackTraceElement[] stack = e.getStackTrace();
// this test should only run when we're not in -usejavac mode
if (!useJavacMode) {
Tester.checkEqual(stack[0].getLineNumber(), 10, "bad line for assert");
}
}
Tester.check(gotAssert, "no assert on call1");
gotAssert = false;
try {
call2();
} catch (AssertionError e) {
gotAssert = true;
StackTraceElement[] stack = e.getStackTrace();
//e.printStackTrace();
// this test should only run when we're not in -usejavac mode
if (!useJavacMode) {
Tester.checkEqual(stack[0].getLineNumber(), 14, "bad line for assert");
}
}
Tester.check(gotAssert, "no assert on call1");
}
public static void call() {}
public static void call1() {}
}
|