Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354573 - [correlation][null]Incorrect "Potential Null Pointer Access" warning
Summary: [correlation][null]Incorrect "Potential Null Pointer Access" warning
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: 4.7 M1   Edit
Assignee: JDT Core Triaged CLA
QA Contact: Ayushman Jain CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 21:59 EDT by Carsten Friedrich CLA
Modified: 2016-08-03 07:58 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Friedrich CLA 2011-08-11 21:59:26 EDT
Build Identifier: Build id: 20110615-0604

The following code gives a "Potential Null Pointer Access" warning for the line "b.toString()" although "b" can't possibly be null at that point. Note that the example is artificial to make it concise (and thus does not make much sense), but based on a real-world case (in which cond, c, cond2, and d are not parameters but computed in the while loop) with the same problem.

public class FalseWarning {
  static void f(boolean cond, Object c, boolean cond2, Object d) {
    while (true) {
      Object a=null;
      Object b=null;
      
      if(cond) {
        a=c;
      }
      
      if(cond2) {
        b=d;
      }
      
      if (a == null && b == null)
        break;

      if (a == null)
        b.toString();
    }
  }
}


Reproducible: Always

Steps to Reproduce:
1. Create new Java Project
2. Create class with content listed above
Comment 1 Ayushman Jain CLA 2011-08-12 02:31:43 EDT
This is a part of correlation analysis which is currently not supported. In this case nullness of b is related to nullness of a
Comment 2 Stephan Herrmann CLA 2016-06-28 17:25:27 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 3 Jay Arthanareeswaran CLA 2016-08-03 07:58:09 EDT
Verified for 4.7 M1.