Bug 332838 - Bogus potential null pointer access warning (regression; works with 3.6)
Summary: Bogus potential null pointer access warning (regression; works with 3.6)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 07:24 EST by Markus Schorn CLA
Modified: 2011-03-07 11:22 EST (History)
4 users (show)

See Also:


Attachments
proposed fix v1.0 + regression tests (4.03 KB, patch)
2011-02-07 02:24 EST, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.