typetools / typetools/checker-framework
false negative when overriding method
Open
@Suvrat1629 is already working on this.
Since Jan 26, 2026.
False Negative (missing warning or unsoundness)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Command
javac -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-processor org.checkerframework.checker.nullness.NullnessChecker \
-cp checker-framework-3.47.0/checker/dist/checker.jar Test.java
File
import org.checkerframework.checker.nullness.qual.*;
import java.util.*;
class A {
<T extends List<Integer>> T m(T x) {
return x;
}
}
class B extends A {
<T extends List<@Nullable Integer>> T m(T x) {
x.add(null);
return x;
}
}
public class Test {
public static void main(String[] args) {
A x = new B();
List<Integer> y = new LinkedList<>();
x.m(y).get(0).toString();
}
}
Actual behavior
The code passes the checks, but there's a NPE at runtime
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Integer.toString()" because the return value of "java.util.List.get(int)" is null
at Test.main(Test.java:22)
Expected behavior
The code should have been rejected because class B changes the signature of the overriden method.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.