Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 129076

Summary: [compiler][null][correlation] instanceof result stored in a boolean not considered
Product: [Eclipse Project] JDT Reporter: Thomas Hallgren <thomas>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P5 CC: stephan.herrmann
Version: 3.2Keywords: helpwanted
Target Milestone: 4.7 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Thomas Hallgren CLA 2006-02-22 17:40:59 EST
The following code yields a null reference warning:

boolean isFoo = (bi instanceof Foo);
if(isFoo)
{
    if(((Foo)bi).getName().equals("xyz"))

but this doesn't:

if(bi instanceof Foo)
{
    if(((Foo)bi).getName().equals("xyz"))
Comment 1 Maxime Daniel CLA 2006-03-23 08:22:06 EST
There is no attempt so far to correlate variables status (beyond direct assignment of the one to the other). Accordingly, the current implementation does not remember any relationship between isFoo and the null status of bi.

We may consider variables correlation post 3.2.
Comment 2 Maxime Daniel CLA 2007-06-19 08:06:24 EDT
Reopening as P5 (since RESOLVED LATER is deprecated).
Comment 3 Stephan Herrmann CLA 2016-06-28 17:18:02 EDT
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.
Comment 4 Sasikanth Bharadwaj CLA 2016-08-02 04:38:32 EDT
Verified for 4.7 M1
Comment 5 Stephan Herrmann CLA 2018-08-30 10:37:32 EDT
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 ***