Debian Codegraph @

checker/tests/nullness/jdkannotations/HashtableTest.java

raw
1 import java.util.Hashtable;
2 import org.checkerframework.checker.nullness.qual.Nullable;
3
4 class HashtableTest {
5
6 public static void main(String[] args) {
7
8 // :: error: (type.argument.type.incompatible)
9 Hashtable<@Nullable Integer, String> ht1 = new Hashtable<>();
10
11 // Suffers null pointer exception
12 ht1.put(null, "hello");
13
14 // :: error: (type.argument.type.incompatible)
15 Hashtable<Integer, @Nullable String> ht2 = new Hashtable<>();
16
17 // Suffers null pointer exception
18 ht2.put(42, null);
19 }
20 }