| Summary: | [compiler][null][correlation] nullpointer check fails within "?" operator statement | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | AndiSmirre <andi> |
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P5 | CC: | martinae, nikolaymetchev, Olivier_Thomann, stephan.herrmann |
| Version: | 3.4 | Keywords: | helpwanted |
| Target Milestone: | 4.7 M1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Thanks for the test case. This pertains to the realm of variables correlation (isNull protects test here), for which we have no firm plans as of today. Lowering priority accordingly. I have a slightly different example. using the Nullable annotation.
I am not sure if the bug fix will be the same:
--------------------------------------
import javax.annotation.Nullable;
public class Bug {
@Nullable
private String a;
String m() {
return (a == null) ? "a" : a.toString();
}
}
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: View the following code with enabled potential nullpointer access check: Object test = null; boolean isNull = test == null; Object hallo = isNull ? "is null" : test.toString(); System.out.println(hallo); // "is null" More information: As you can see, the else operator of the "?" statement marks the variable "test" to be a potential nullpointer access. But this is not possible, as the nullpointer access has been checked in the previous line and it is prevented by the "?" operator.