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

Bug 354573

Summary: [correlation][null]Incorrect "Potential Null Pointer Access" warning
Product: [Eclipse Project] JDT Reporter: Carsten Friedrich <Carsten.Friedrich>
Component: CoreAssignee: JDT Core Triaged <jdt-core-triaged>
Status: VERIFIED WONTFIX QA Contact: Ayushman Jain <amj87.iitr>
Severity: minor    
Priority: P3 CC: amj87.iitr, stephan.herrmann
Version: 3.8   
Target Milestone: 4.7 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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.