### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java,v retrieving revision 1.51 diff -u -r1.51 LoopingFlowContext.java --- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 23 Aug 2010 08:41:25 -0000 1.51 +++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 5 Feb 2011 23:30:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -524,9 +524,13 @@ if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { recordNullReference(local, reference, checkType); } - } else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { + } else if (flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { + return; // no reason to complain + } else { if (flowInfo.isPotentiallyNonNull(local)) { recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK); + } else if (flowInfo.isPotentiallyNull(local)) { + recordNullReference(local, reference, CAN_ONLY_NULL | checkType & CONTEXT_MASK); } else { if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { recordNullReference(local, reference, checkType); #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v retrieving revision 1.109 diff -u -r1.109 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 19 Jan 2011 05:29:57 -0000 1.109 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 5 Feb 2011 23:31:00 -0000 @@ -13832,4 +13832,21 @@ "}"}, ""); } +// Bug 336428 - [compiler][null] bogus warning "redundant null check" in condition of do {} while() loop +public void testBug336428() { + this.runConformTest( + new String[] { + "DoWhileBug.java", + "public class DoWhileBug {\n" + + " void test(boolean b1, Object o1) {\n" + + " Object o2 = new Object();\n" + + " do {\n" + + " if (b1)\n" + + " o1 = null;\n" + + " } while ((o2 = o1) != null);\n" + + " }\n" + + "}" + }, + ""); +} } \ No newline at end of file