Bug 80252 - False positive inconsistent null check
Summary: False positive inconsistent null check
Status: RESOLVED DUPLICATE of bug 110030
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-06 06:17 EST by Tobias Widmer CLA
Modified: 2005-11-28 07:32 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2004-12-06 06:17:19 EST
200412011139:

Steps to reproduce:

class C {
  void foo() {
    String s;
    if (s instanceof String) {
      ;
    } else if (s != null) {
      // Do something
    }
  }
}

The "s != null" check is necessary since "instanceof" does not assume "s" to 
be non-null.
Comment 1 Philipe Mulet CLA 2004-12-06 06:25:54 EST
The null ref diagnosis is still in its early stage. Thanks for reporting anyway.
Comment 2 Tobias Widmer CLA 2004-12-10 11:38:03 EST
The following case is a false positive as well;
		
for (int i= 0; i < n; i++) {
  String s= getSomething();
  if (s!= null)
    return s;
}
return null;
Comment 3 Vladimir Dolzhenko CLA 2005-06-22 00:58:58 EDT
System.out.println(null instanceof Object);

occur warning: The expression of type null is already an instance of type Object.
That is really incorrect.
Comment 4 Vladimir Dolzhenko CLA 2005-06-22 00:59:31 EDT
System.out.println(null instanceof Object);

occur warning: The expression of type null is already an instance of type Object.
That is really incorrect.
Comment 5 Vladimir Dolzhenko CLA 2005-06-22 01:00:54 EDT
System.out.println(null instanceof Object);

occur warning: The expression of type null is already an instance of type Object.
That is really incorrect.
Comment 6 Philipe Mulet CLA 2005-06-22 04:40:29 EDT
The latter comment is a different issue, entered bug 101208.
Comment 7 Maxime Daniel CLA 2005-11-28 07:32:33 EST
Added two test cases to take into account comments 0 and 2 (NullReferenceTests#test1037 and test1038).

*** This bug has been marked as a duplicate of 110030 ***