You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjava.util.*;
importorg.checkerframework.checker.nullness.qual.*;
publicclassTest {
staticpublicvoidmain(String[] args) {
List<List<? extendsNumber>> lists = newArrayList<>();
List<? superList<? extendsNumber>> y = lists;
// This assignment is not null-safeList<? super@NullableList<? extendsNumber>> x = y;
x.add(null);
lists.get(0).toString();
}
}
Actual behavior
The code passes the checks of the checker, but there's NPE
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.List.get(int)" is null
at Test.main(Test.java:12)
Expected behavior
The assignment List<? super @Nullable List<? extends Number>> x = y; should have been rejected.
The text was updated successfully, but these errors were encountered:
Command
File
Actual behavior
The code passes the checks of the checker, but there's NPE
Expected behavior
The assignment
List<? super @Nullable List<? extends Number>> x = y;
should have been rejected.The text was updated successfully, but these errors were encountered: