blob: a0a8f36fe6d60dd09f0ff191f0ebdc1c5c4695f3 (
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
|
import org.aspectj.testing.Tester;
import org.aspectj.testing.Tester;
/** @testcase from biojava: org/biojava/bio/dp/SimpleMarkovModel.java:384 */
public class ConstructorFlow {
final Runnable runner; // remove final and compile succeeds
Runnable nonfinal;
String one;
/** @testcase PUREJAVA flow analysis where final variable set in another constructor */
public ConstructorFlow(String one, String two) {
this(one);
runner.run(); // incorrect CE: Field runner might not have a value
nonfinal.run(); // expecting NPE
}
public ConstructorFlow(String one) {
this.one = one;
runner = new Runnable() {
public void run() {
Tester.event("runner.run()");
}};
}
public static void main(String[] args) {
Tester.expectEvent("NullPointerException");
Tester.expectEvent("runner.run()");
try {
new ConstructorFlow("one", "two");
Tester.check(false, "expected NPE");
} catch (NullPointerException npe) {
Tester.event("NullPointerException");
}
Tester.checkAllEvents();
}
}
|