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
The nullness checker doesn't report any diagnostics for the following program, which fails at runtime with an NPE:
importorg.checkerframework.checker.nullness.qual.Nullable;
interfaceC<T> {
Tget();
}
interfaceX {
C<? extendsObject> get();
}
interfaceYextendsX {
@OverrideC<? superObject> get(); // should be an error
}
classA {
publicstaticvoidmain(String[] args) {
C<@NullableObject> c = () -> null;
Yy = () -> c;
Xx = y;
x.get().get().toString(); // NPE
}
}
$ ./checker-framework-3.21.1/checker/bin/javac -processor org.checkerframework.checker.nullness.NullnessChecker A.java
$ java A
Exception in thread "main" java.lang.NullPointerException
at A.main(A.java:21)
The text was updated successfully, but these errors were encountered:
The problem is that javac "captures" C<? super Object> to C<Object>. (I think this is a javac bug, that I thought we reported, but I can't find it.) This happens when the super bound of a wildcard is the same as the upper bound of the type parameter for which it is an argument. I noticed this problem when implementing capture conversion. (We have some tests in checker/tests/tainting/SameTypeBounds.java.)
The Checker Framework works around this by using the the super bound as the annotation on the new type argument. So C< @Nullable ? super @NonNull Object> becomes C<@NonNull Object>. This is unsound as demonstrated in this example. The Checker Framework should also require that super bounds that are captured in this way have the same annotations on the super and extends bounds. So, in this example, the Checker Framework should issue an invalid type error on C< @Nullable ? super @NonNull Object>.
The nullness checker doesn't report any diagnostics for the following program, which fails at runtime with an NPE:
The text was updated successfully, but these errors were encountered: