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

Bug 133173

Summary: [compiler][null][correlation] False positive with indirect comparison
Product: [Eclipse Project] JDT Reporter: Eugene Kuleshov <ekuleshov>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P5 CC: kuaw26, stephan.herrmann
Version: 3.2Keywords: helpwanted
Target Milestone: 4.7 M1   
Hardware: PC   
OS: Windows All   
Whiteboard:

Description Eugene Kuleshov CLA 2006-03-24 12:18:56 EST
Here is rather sily piece of code that is confusing null refrence analyzer. Code in for loop is neve executed when args is null, but yet reported that args variable can be null.

  public void aaa(String[] args) {
    String[] vars = new String[args == null ? 0 : args.length];
    for (int i = 0; i < vars.length; ++i) {
      System.err.println(args[i]);
    }
  }

Unfortunately this happening in some legacy code that can't be easily changed to eliminate such warning.
Comment 1 Maxime Daniel CLA 2006-03-27 03:49:11 EST
Variables correlation in general is not in scope for our null analysis, as far as 3.2 is concerned. Here, we would need args null status to be guarded by vars length. At the extreme, a pattern could be hard coded. It would be quite convoluted though, and still would need that vars be made final, which is not practical in legacy code either.
Comment 2 Eugene Kuleshov CLA 2006-03-27 11:18:12 EST
I wonder how FindBugs analyzer approached this case. It does not raise false positive for this.
Comment 3 Maxime Daniel CLA 2006-03-28 03:44:45 EST
I haven't looked at their code.
Comment 4 Maxime Daniel CLA 2007-06-19 08:07:23 EDT
Reopening as P5 (since RESOLVED LATER is deprecated).
Comment 5 Ayushman Jain CLA 2009-12-15 06:02:39 EST
*** Bug 260293 has been marked as a duplicate of this bug. ***
Comment 6 Stephan Herrmann CLA 2016-06-28 17:17:22 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 7 Sasikanth Bharadwaj CLA 2016-08-02 04:35:32 EDT
Verified for 4.7 M1
Comment 8 Stephan Herrmann CLA 2018-08-30 10:38:23 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 ***