blob: 1ea56b2b842d9492a6b8c569f75fb426bf4fe9cc (
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
|
/** @testcase PR#31724 omnibus declare-warning test */
public class DeclareWarning {
static {
if (null == System.getProperty("ignore")) { // CW 5
throw new Error("never thrown");
}
}
static int staticInt;
int instanceInt;
public static void main (String[] args) {
DeclareWarning dw = new DeclareWarning(); // CW 12..18
int i = staticInt;
i = dw.instanceInt;
staticInt = 2;
dw.instanceInt = 2;
run();
dw.irun();
throw new Error("compile-only test");
}
public static void run() {} // CW 21..23
public void irun() {}
public DeclareWarning() {
try {
long l = System.currentTimeMillis();
if (0l == l) {
throw new Error("never thrown");
} else if (1l == l) {
throw new RuntimeException("never thrown");
} else if (2l == l) {
throw new OutOfMemoryError("never thrown");
}
} catch (OutOfMemoryError e) {
// CW 34
System.err.println("never run");
} catch (Error e) {
// CW 37
System.err.println("never run");
} catch (RuntimeException x) {
// CW 40
System.err.println("never run");
}
}
}
aspect A {
declare warning: staticinitialization(DeclareWarning)
: "staticinitialization(DeclareWarning)";
declare warning: initialization(DeclareWarning.new(..))
: "initialization(DeclareWarning)";
declare warning: get(int staticInt) : "get staticInt";
declare warning: get(int instanceInt) : "get instanceInt";
declare warning: set(int staticInt) : "set staticInt";
declare warning: set(int instanceInt) : "set instanceInt";
declare warning: call(void run()) : "call(void run())";
declare warning: call(void irun()) : "call(void irun())";
declare warning: call(DeclareWarning.new())
: "call(DeclareWarning.new())";
declare warning: execution(void run()) : "execution(void run())";
declare warning: execution(void irun()) : "execution(void irun())";
declare warning: execution(DeclareWarning.new())
: "execution(DeclareWarning.new())";
declare warning: handler(Error) : "handler(Error)";
declare warning: handler(OutOfMemoryError) && within(DeclareWarning)
: "handler(OutOfMemoryError) && within(DeclareWarning)";
declare warning: handler(RuntimeException)
&& withincode(DeclareWarning.new())
: "handler(RuntimeException) && withincode(DeclareWarning.new())";
declare warning: adviceexecution() && within(A)
: "adviceExecution() && within(A)";
before() : initialization(DeclareWarning.new(..)) {
// CW 74
long l = System.currentTimeMillis();
if (0l == l) {
throw new Error("never thrown");
}
}
}
|