typetools / typetools/checker-framework
Anonymous inner class and @MonotonicNonNull
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Not sure if this is a bug or a misunderstanding on my part, but I think I'm
getting a false positive. Using Checker Framework v1.7.1 on Java 1.7.0_25, on
Mac OS X 10.8.5.
/*>>> import checkers.nullness.quals.MonotonicNonNull; */
abstract class Monotonic
{
public /*@MonotonicNonNull*/String header;
public void f()
{
if (header == null) {
write("null");
}
else {
runWithRetry(new Runnable() {
public void run() {
write(header); // <-- error here
}
});
}
}
public abstract void write(String s);
public abstract void runWithRetry(Runnable r);
}
I expected no errors, but I got one:
# java -jar binary/checkers.jar -processor checkers.nullness.NullnessChecker
Monotonic.java
Monotonic.java:15: error: incompatible types in argument.
write(header);
^
found : @Initialized @MonotonicNonNull String
required: @Initialized @NonNull String
1 error
If I replace the runWithRetry and the anonymous inner class with a simple
"write(header)", there are no errors.
Original issue reported on code.google.com by kan...@cakoose.com on 18 Dec 2013 at 1:39
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.
Research direction
Reproduce the report from the Monotonic.java example with binary/checkers.jar and checkers.nullness.NullnessChecker using the supplied command. Trace how the anonymous Runnable affects the @MonotonicNonNull header and determine whether the diagnostic is expected; done means documenting the behavior or resolving it with a regression case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100