Community
Participate
Working Groups
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.
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.
The latter comment is a different issue, entered bug 101208.
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 ***