Debian Codegraph @

checker/tests/nullness/init/Issue409.java

raw
1 // Test case for Issue #409
2 // https://github.com/typetools/checker-framework/issues/409
3
4 // @skip-test until the issue is fixed
5
6 public class Issue409 {
7 public static void main(String[] args) {
8 new Callback();
9 }
10 }
11
12 class Callback {
13
14 class MyProc {
15 public void call() {
16 doStuff();
17 }
18 }
19
20 String foo;
21
22 Callback() {
23 MyProc p = new MyProc();
24 // This call is illegal. It passes an @UnderInitialization outer this, but MyProc.call is
25 // declared to take an @Initialized outer this (whith is the default type).
26 // :: error: (method.invocation.invalid)
27 p.call();
28 foo = "hello";
29 }
30
31 void doStuff() {
32 System.out.println(
33 foo.toLowerCase()); // this line throws a NullPointerException at run time
34 }
35 }