| Summary: | False positive inconsistent null check | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Tobias Widmer <tobias_widmer> |
| Component: | Core | Assignee: | Maxime Daniel <maxime_daniel> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | markus.kell.r |
| Version: | 3.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
The null ref diagnosis is still in its early stage. Thanks for reporting anyway. 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;
System.out.println(null instanceof Object); occur warning: The expression of type null is already an instance of type Object. That is really incorrect. System.out.println(null instanceof Object); occur warning: The expression of type null is already an instance of type Object. That is really incorrect. System.out.println(null instanceof Object); occur warning: The expression of type null is already an instance of type Object. That is really incorrect. The latter comment is a different issue, entered bug 101208. |
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.