Index: compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java,v --- compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java 28 Mar 2006 20:29:56 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java 4 Oct 2006 15:33:38 -0000 @@ -50,8 +50,8 @@ return flowInfo; } else { LabelFlowContext labelContext; - FlowInfo mergedInfo = - statement + FlowInfo statementInfo, mergedInfo; + if (((statementInfo = statement .analyseCode( currentScope, (labelContext = @@ -61,8 +61,13 @@ label, (targetLabel = new BranchLabel()), currentScope)), - flowInfo) - .mergedWith(labelContext.initsOnBreak); + flowInfo)).tagBits & FlowInfo.UNREACHABLE) != 0) { + // an embedded loop has had no chance to reinject forgotten null info + mergedInfo = flowInfo.unconditionalCopy(). + addInitializationsFrom(labelContext.initsOnBreak); + } else { + mergedInfo = statementInfo.mergedWith(labelContext.initsOnBreak); + } mergedInitStateIndex = currentScope.methodScope().recordInitializationStates(mergedInfo); if ((this.bits & ASTNode.LabelUsed) == 0) { 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 --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 3 Oct 2006 15:19:13 -0000 1.48 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 4 Oct 2006 15:33:44 -0000 @@ -3739,7 +3739,7 @@ // null analysis - while // https://bugs.eclipse.org/bugs/show_bug.cgi?id=134848 // false positive after nested loop with break to explicit label -public void _test0456_while_nested_explicit_label() { +public void test0456_while_nested_explicit_label() { this.runConformTest( new String[] { "X.java", @@ -3788,6 +3788,29 @@ ""); } +// null analysis - while +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=134848 +// variant: no label yields no problem +public void test0458_while_nested_explicit_label() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(Object o) {\n" + + " while (true) {\n" + + " if (o != null) {\n" + + " o.toString();\n" + + " while (true) {\n" + + " break;\n" + + " }\n" + + " o.toString();\n" + // must not complain here + " }\n" + + " }\n" + + " }\n" + + "}"}, + ""); +} + // null analysis -- try/finally public void test0500_try_finally() { this.runConformTest(