Community
Participate
Working Groups
I20070531-0010 The following test case raises no error while it should: public class X { void foo(Object o) { if (o != null) { for (int i = 0; i < Integer.MAX_VALUE; i++) { if (o == null) { // cannot be null } } } } }
Entered (inactive) test case NullReferenceTest#745.
*** Bug 212013 has been marked as a duplicate of this bug. ***
A similar case but the other way 'round (missing "redundant null check"): public class Try { public static void main(String[] args) { Number n= getNumber(); if (n instanceof Double) { Double d= (Double) n; if (d != null && d.isNaN()) { //"redundant null check" (good) System.out.println("outside loop"); } for (int i= 0; i < 10; i++) { if (d != null && d.isNaN()) { //"redundant null check" missing System.out.println("inside loop"); } } } } private static Number getNumber() { return new Double(Math.sqrt(-1)); } }
*** Bug 291418 has been marked as a duplicate of this bug. ***
Patch is provided in bug 291418.
Released for 3.6M4. Added regression tests in: org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#testBug291418a org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#testBug291418b
Verified for 3.6M4 using Build id: I20091207-1800. The inverse problem mentioned in comment#3 is still there, Ayush, I believe this case is covered in the several already existing defects ? If so, please add an annotation here to that effect, otherwise, open a separate defect for that -- Thanks.
(In reply to comment #3) > A similar case but the other way 'round (missing "redundant null check"): > This case is still not rectified with this bug. This, although not an exact duplicate, is a close relative of bug 129581 and bug 190623. All these cases pertain to sequel null errors, where a variable checked against null gets tainted and loses the surety of being non null subsequently. This problem should also be fixed along with these related bugs. This case has been added as comment #9 on bug 190623.
> This case has been added as comment #9 on bug 190623. Thanks. BTW: To create a direct link, switch comment and bug #, e.g.: Bug 190623 comment 9.
*** Bug 220788 has been marked as a duplicate of this bug. ***