Bug 332838

Summary: Bogus potential null pointer access warning (regression; works with 3.6)
Product: [Eclipse Project] JDT Reporter: Markus Schorn <mschorn.eclipse>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert, Olivier_Thomann, stephan.herrmann
Version: 3.7   
Target Milestone: 3.7 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed fix v1.0 + regression tests none

Description Markus Schorn CLA 2010-12-17 07:24:26 EST
Eclipse SDK, Version: 3.7.0, Build id: I20101208-1300

public class Info {
  public void test(Info[] infos)  {
    for (final Info info : infos) {
      if (info != null) {
        assert info.checkSomething();
        info.doSomething();             // Potential NPA warning here!
      }
    }
  }

  void doSomething()  {}
  boolean checkSomething() {return true;}
}
Comment 1 Ayushman Jain CLA 2010-12-17 07:42:11 EST
I'll investigate
Comment 2 Dani Megert CLA 2011-01-26 10:42:08 EST
Ayush, please fix this for M6.
Comment 3 Ayushman Jain CLA 2011-02-07 02:24:23 EST
Created attachment 188421 [details]
proposed fix v1.0 + regression tests

The problem is in the incorrect merging of null info when the option "include null info from asserts" is disabled. 

This has been corrected in the above fix.

This also now gives a NPE warning instead of pot. NPE warning for the case:
for (final Info info : infos) {
      if (info == null) {   
          assert info.checkSomething();
          info.doSomething();             // NPE
        }
    }
Comment 4 Ayushman Jain CLA 2011-02-07 11:18:28 EST
Released in HEAD for 3.7 M6
Comment 5 Olivier Thomann CLA 2011-03-07 11:22:54 EST
Verified for 3.7M6.