File: Issue2235.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (30 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (3)
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
// Test case that was submitted in Issue 2235, but is caused
// by a false negative from Issue 979
// https://github.com/typetools/checker-framework/issues/979

// Skip until correct error is issued.
// @skip-test

public class Issue2235 {
    // Simple wrapper class with a public generic method
    // to make an instance:
    static class Holder<T> {
        T t;

        private Holder(T t) {
            this.t = t;
        }

        public static <T> Holder<T> make(T t) {
            return new Holder<>(t);
        }
    }

    public static void main(String[] args) throws Exception {
        // Null is hidden via nested calls, but assigned to a non-null type:
        // :: error: (TODO)
        Holder<Holder<String>> h = Holder.make(Holder.make(null));
        // NullPointerException will fire here:
        h.t.t.toString();
    }
}