typetools / typetools/checker-framework
Implicit "this" passed through non-static inner class loses @UnderInitialization
Open
Nobody has claimed this yet.
bug
False Negative (missing warning or unsoundness)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
The following code fails at runtime with an NPE, but does not cause an error in
the checker framework. I'm guessing, but I believe this is because when I call
p.call(), the "this" which is passed through to the inner class loses it's
@UnderInitialization.
class Callback {
static interface Proc {
void call();
}
Proc p;
class MyProc implements Proc {
@Override
public void call() {
doStuff();
}
}
String foo;
Callback() {
p = new MyProc();
p.call();
foo = "hello";
}
void doStuff() {
System.out.println(foo.toLowerCase());
}
public static void main(String[] args) {
new Callback();
}
}
Original issue reported on code.google.com by eatnumb...@google.com on 9 Mar 2015 at 8:41
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
Start by reducing the Java example to a checker-framework test case and reproduce the missing error around the non-static inner class callback. Trace how the implicit this reference is propagated through p.call() and verify that the checker reports the unsafe access before foo is initialized.
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