Open GoogleCodeExporter opened 9 years ago
If the get() method throws an exception, then the assignment to p does not
occur.
For that reason, the warning is correct. (The warning isn't related to p nor
the result of get being possibly null.)
If you have suggestions for how to make subtle issues like this clearer to
users of the Checker Framework, that would be great. Thanks!
Original comment by michael.ernst@gmail.com
on 16 Jul 2014 at 12:01
If 'get' is a field, the same diagnostic is reported. Is there another place
the assignment could fail?
e.g.
class Test {
static class Provider {
public final Object get = new Object();
}
Object execute(Provider p) {
final Object result;
try {
result = p.get;
} finally {
}
return result;
}
}
Original comment by cus...@google.com
on 16 Jul 2014 at 12:36
This looks similar to Issue 293, but separate.
In the CFG, p.get might create a NPE (the CFG doesn't consider the Checker
Framework types). Then after the merge "result" may be unitialized and nullable.
We need to prune paths based on the Checker Framework types. Because p is
@NonNull, we know that p.get cannot throw an NPE. Therefore, we don't need to
merge with that store.
Would that make sense?
Original comment by wdi...@gmail.com
on 16 Jul 2014 at 2:34
Original comment by wdi...@gmail.com
on 16 Jul 2014 at 2:35
Original issue reported on code.google.com by
cus...@google.com
on 15 Jul 2014 at 11:37