import java.util.function.*;
import org.checkerframework.checker.nullness.qual.*;
class A<T extends Function<Integer, Integer>> {
T f;
A(T f) {
this.f = f;
}
T get() { return this.f; }
}
class Test {
static public void main(String[] args) {
new A<>(Test::m).get().apply(1).intValue();
}
public static <T extends @Nullable Object> T m(T x) { return (T) null; }
}
Actual behavior
There's a NPE at runtime
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.function.Function.apply(Object)" is null
at Test.main(Test.java:14)
Command
File
Actual behavior
There's a NPE at runtime
Expected behavior
The code should have been rejected.