View | Details | Raw Unified | Return to bug 134848 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java (-4 / +13 lines)
Lines 50-57 Link Here
50
			return flowInfo;
50
			return flowInfo;
51
		} else {
51
		} else {
52
			LabelFlowContext labelContext;
52
			LabelFlowContext labelContext;
53
			FlowInfo mergedInfo =
53
			FlowInfo statementInfo, mergedInfo;
54
				statement
54
			if (((statementInfo = statement
55
					.analyseCode(
55
					.analyseCode(
56
						currentScope,
56
						currentScope,
57
						(labelContext =
57
						(labelContext =
Lines 61-68 Link Here
61
								label,
61
								label,
62
								(targetLabel = new BranchLabel()),
62
								(targetLabel = new BranchLabel()),
63
								currentScope)),
63
								currentScope)),
64
						flowInfo)
64
						flowInfo)).tagBits & FlowInfo.UNREACHABLE) != 0) {
65
					.mergedWith(labelContext.initsOnBreak);
65
				if ((labelContext.initsOnBreak.tagBits & FlowInfo.UNREACHABLE) == 0) {
66
					// an embedded loop has had no chance to reinject forgotten null info
67
					mergedInfo = flowInfo.unconditionalCopy().
68
						addInitializationsFrom(labelContext.initsOnBreak);
69
				} else {
70
					mergedInfo = labelContext.initsOnBreak;
71
				}
72
			} else {
73
				mergedInfo = statementInfo.mergedWith(labelContext.initsOnBreak);
74
			}
66
			mergedInitStateIndex =
75
			mergedInitStateIndex =
67
				currentScope.methodScope().recordInitializationStates(mergedInfo);
76
				currentScope.methodScope().recordInitializationStates(mergedInfo);
68
			if ((this.bits & ASTNode.LabelUsed) == 0) {
77
			if ((this.bits & ASTNode.LabelUsed) == 0) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (-1 / +24 lines)
Lines 3739-3745 Link Here
3739
// null analysis - while
3739
// null analysis - while
3740
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=134848
3740
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=134848
3741
// false positive after nested loop with break to explicit label
3741
// false positive after nested loop with break to explicit label
3742
public void _test0456_while_nested_explicit_label() {
3742
public void test0456_while_nested_explicit_label() {
3743
	this.runConformTest(
3743
	this.runConformTest(
3744
		new String[] {
3744
		new String[] {
3745
			"X.java",
3745
			"X.java",
Lines 3788-3793 Link Here
3788
		"");
3788
		"");
3789
} 
3789
} 
3790
3790
3791
// null analysis - while
3792
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=134848
3793
// variant: no label yields no problem
3794
public void test0458_while_nested_explicit_label() {
3795
	this.runConformTest(
3796
		new String[] {
3797
			"X.java",
3798
			"public class X {\n" + 
3799
			"  void foo(Object o) {\n" + 
3800
			"    while (true) {\n" + 
3801
			"      if (o != null) {\n" + 
3802
			"        o.toString();\n" + 
3803
			"        while (true) {\n" + 
3804
			"          break;\n" + 
3805
			"        }\n" + 
3806
			"        o.toString();\n" + // must not complain here 
3807
			"      }\n" + 
3808
			"    }\n" + 
3809
			"  }\n" + 
3810
			"}"},
3811
		"");
3812
} 
3813
3791
// null analysis -- try/finally
3814
// null analysis -- try/finally
3792
public void test0500_try_finally() {
3815
public void test0500_try_finally() {
3793
	this.runConformTest(
3816
	this.runConformTest(

Return to bug 134848