blob: e325a6fb9b2d7b841dd05908352c9d38d76208aa (
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
|
import org.aspectj.testing.Tester;
/** @testcase PUREJAVA PR#725 asserts in aspect and declared methods */
public class IntroducedAssertion {
public static void main (String[] args) {
IntroducedAssertion.class.getClassLoader().setClassAssertionStatus("A", true);
IntroducedAssertion.class.getClassLoader().setClassAssertionStatus("B", true);
boolean result = false;
try {
C.method(null);
} catch (AssertionError e) {
result = true;
}
Tester.check(result, "no assert: C.method(null)");
result = false;
try {
new C(); // field initializer
} catch (AssertionError e) {
result = true;
}
Tester.check(result, "no assert: new C()");
result = false;
try {
new D().method(null);
} catch (AssertionError e) {
result = true;
}
Tester.check(result, "no assert: new D().method(null)");
}
}
class C {}
class D {}
aspect B {
int C.i = method(null);
// assertion in any introduced code conflicts with any local
static int C.method( Object o) {
assert o != null ;
return 0;
}
}
aspect A {
void D.method( Object o) {
assert o != null ;
}
// assertion in any introduced method conflicts with any local
void method() {
assert null != System.getProperty("java.version");
}
// XXX build test cases for other local variants - these work
/*
static {
assert null != System.getProperty("java.version");
}
static void aStaticMethod( Object parameter ) {
assert parameter != null ;
}
*/
}
|