| Summary: | [compiler][null][correlation] False positive on potential null pointer access warning when re-using a condition | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Daniel Aborg <eclipse.daniel.aborg> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P5 | CC: | max.gilead, stephan.herrmann |
| Version: | 3.3 | Keywords: | helpwanted |
| Target Milestone: | 4.7 M1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
The warning disappears if you replace the if with a conditional, but that is not always possible (e.g. the if branches contain multiple statements). This is a case of variables correlation. We currently have no plans to address that class of null analysis issues. Lowering the priority accordingly. I believe this is the same issue so I'll post a bit another test case here:
void test(final Object a, final Object b) {
if (a == null && b == null) {
return;
}
if (a == null && b != null) {
return;
}
System.out.println(a.hashCode()); // Potential null pointer access
}
Bulk closing all compiler bugs tagged [null][correlation], because we have no plans to add such a feature: it would be a tremendous implementation effort, beyond our current man power, and may be impossible to achieve within the desired performance bounds. If s.o. has a viable strategy or even implementation for such a feature, I'm all ears. Verified for 4.7 M1. I created a new umbrella RFE outlining what would be needed to address this issue. *** This bug has been marked as a duplicate of bug 538421 *** |
Build ID: I20070621-1340 Steps To Reproduce: The following code produces a potential null pointer warning: final String s; if (condition) { s = "Hello"; } else { s = null; } if (condition) { s.indexOf(1); } As does this code: String s = null; if (condition) { s = "Hello"; } if (condition) { s.indexOf(1); }