| Summary: | [compiler][null][correlation] Wrong "potential null pointer access" | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Mauro Molinari <mauromol> |
| Component: | Core | Assignee: | JDT Core Triaged <jdt-core-triaged> |
| Status: | CLOSED DUPLICATE | QA Contact: | Ayushman Jain <amj87.iitr> |
| Severity: | enhancement | ||
| Priority: | P5 | CC: | axel.gross, christian.dietrich.opensource, david, kstenerud, manoj.palat, max.gilead, Olivier_Thomann, stephan.herrmann |
| Version: | 3.5 | Keywords: | helpwanted |
| Target Milestone: | 4.7 M1 | ||
| Hardware: | PC | ||
| OS: | Windows Server 2003 | ||
| Whiteboard: | |||
|
Description
Mauro Molinari
Fixing this would require analysis of the correlation of v1 and v2, which we currently don't do. *** Bug 244222 has been marked as a duplicate of this bug. *** import org.eclipse.jdt.annotation.*;
public class X {
@Nullable Object o1, o2;
/**
* @param other
*/
public void foo(X other) {
if (o1 == null && o1 != o2)
System.out.println(o2.toString());//get a "potential null pointer accesss warning here.
}
}
Stephan: I believe the issue mentioned in the test code above is related to this bug.
(In reply to comment #3) If you change your example to using local variables instead of nullable fields, the warning disappears as you expect. Generally we do consider correlation against known-to-be-null values (as compared to general (v1==v2) correlation for unknown values). So in this example the reason for not detecting the pattern is not because of correlation in itself, but because a level of sophistication is needed that simply is not (and shall not) be provided by syntactic analysis for nullable fields. 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. *** Bug 513639 has been marked as a duplicate of this bug. *** 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 *** |