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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java (+6 lines)
Lines 60-65 Link Here
60
			}
60
			}
61
		}
61
		}
62
		rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo);
62
		rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo);
63
		if ((this.left.implicitConversion & TypeIds.UNBOXING) != 0) {
64
			this.left.checkNPE(currentScope, flowContext, flowInfo);
65
		}
66
		if ((this.right.implicitConversion & TypeIds.UNBOXING) != 0) {
67
			this.right.checkNPE(currentScope, flowContext, flowInfo);
68
		}
63
		FlowInfo mergedInfo = FlowInfo.conditional(
69
		FlowInfo mergedInfo = FlowInfo.conditional(
64
				rightInfo.safeInitsWhenTrue(),
70
				rightInfo.safeInitsWhenTrue(),
65
				leftInfo.initsWhenFalse().unconditionalInits().mergedWith(
71
				leftInfo.initsWhenFalse().unconditionalInits().mergedWith(
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (+3 lines)
Lines 39-44 Link Here
39
				this.arguments[i]
39
				this.arguments[i]
40
					.analyseCode(currentScope, flowContext, flowInfo)
40
					.analyseCode(currentScope, flowContext, flowInfo)
41
					.unconditionalInits();
41
					.unconditionalInits();
42
			if ((this.arguments[i].implicitConversion & TypeIds.UNBOXING) != 0) {
43
				this.arguments[i].checkNPE(currentScope, flowContext, flowInfo);
44
			}
42
		}
45
		}
43
	}
46
	}
44
	// record some dependency information for exception types
47
	// record some dependency information for exception types
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java (+3 lines)
Lines 30-35 Link Here
30
			Expression dim;
30
			Expression dim;
31
			if ((dim = this.dimensions[i]) != null) {
31
			if ((dim = this.dimensions[i]) != null) {
32
				flowInfo = dim.analyseCode(currentScope, flowContext, flowInfo);
32
				flowInfo = dim.analyseCode(currentScope, flowContext, flowInfo);
33
				if ((dim.implicitConversion & TypeIds.UNBOXING) != 0) {
34
					dim.checkNPE(currentScope, flowContext, flowInfo);
35
				}
33
			}
36
			}
34
		}
37
		}
35
		if (this.initializer != null) {
38
		if (this.initializer != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java (+3 lines)
Lines 42-47 Link Here
42
	this.preAssertInitStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo);
42
	this.preAssertInitStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo);
43
43
44
	Constant cst = this.assertExpression.optimizedBooleanConstant();
44
	Constant cst = this.assertExpression.optimizedBooleanConstant();
45
	if ((this.assertExpression.implicitConversion & TypeIds.UNBOXING) != 0) {
46
		this.assertExpression.checkNPE(currentScope, flowContext, flowInfo);
47
	}
45
	boolean isOptimizedTrueAssertion = cst != Constant.NotAConstant && cst.booleanValue() == true;
48
	boolean isOptimizedTrueAssertion = cst != Constant.NotAConstant && cst.booleanValue() == true;
46
	boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
49
	boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
47
	
50
	
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java (+3 lines)
Lines 37-42 Link Here
37
// a field reference, a blank final field reference, a field of an enclosing instance or
37
// a field reference, a blank final field reference, a field of an enclosing instance or
38
// just a local variable.
38
// just a local variable.
39
	LocalVariableBinding local = this.lhs.localVariableBinding();
39
	LocalVariableBinding local = this.lhs.localVariableBinding();
40
	if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) {
41
		this.expression.checkNPE(currentScope, flowContext, flowInfo);
42
	}
40
	int nullStatus = this.expression.nullStatus(flowInfo);
43
	int nullStatus = this.expression.nullStatus(flowInfo);
41
	if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) {
44
	if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) {
42
		if (nullStatus == FlowInfo.NULL) {
45
		if (nullStatus == FlowInfo.NULL) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java (-1 / +5 lines)
Lines 47-55 Link Here
47
}
47
}
48
48
49
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
49
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
50
	return this.expression
50
	FlowInfo result = this.expression
51
		.analyseCode(currentScope, flowContext, flowInfo)
51
		.analyseCode(currentScope, flowContext, flowInfo)
52
		.unconditionalInits();
52
		.unconditionalInits();
53
	if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) {
54
		this.expression.checkNPE(currentScope, flowContext, flowInfo);
55
	}
56
	return result;
53
}
57
}
54
58
55
/**
59
/**
(-)compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java (+19 lines)
Lines 57-62 Link Here
57
57
58
	int previousMode = flowInfo.reachMode();
58
	int previousMode = flowInfo.reachMode();
59
59
60
	FlowInfo initsOnCondition = flowInfo;
61
60
	UnconditionalFlowInfo actionInfo = flowInfo.nullInfoLessUnconditionalCopy();
62
	UnconditionalFlowInfo actionInfo = flowInfo.nullInfoLessUnconditionalCopy();
61
	// we need to collect the contribution to nulls of the coming paths through the
63
	// we need to collect the contribution to nulls of the coming paths through the
62
	// loop, be they falling through normally or branched to break, continue labels
64
	// loop, be they falling through normally or branched to break, continue labels
Lines 72-77 Link Here
72
				FlowInfo.UNREACHABLE) != 0) {
74
				FlowInfo.UNREACHABLE) != 0) {
73
			this.continueLabel = null;
75
			this.continueLabel = null;
74
		}
76
		}
77
		if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
78
			if ((actionInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
79
				if (loopingContext.initsOnContinue == FlowInfo.DEAD_END)
80
					initsOnCondition = flowInfo.unconditionalCopy().
81
											addInitializationsFrom(actionInfo);
82
				else
83
					initsOnCondition = flowInfo.unconditionalCopy().
84
											addPotentialInitializationsFrom(actionInfo).
85
											addInitializationsFrom(loopingContext.initsOnContinue);
86
			} else if (loopingContext.initsOnContinue != FlowInfo.DEAD_END) {
87
				initsOnCondition = flowInfo.unconditionalCopy().
88
											addInitializationsFrom(loopingContext.initsOnContinue);
89
			}
90
		}
91
	}
92
	if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
93
		this.condition.checkNPE(currentScope, flowContext, initsOnCondition);
75
	}
94
	}
76
	/* Reset reach mode, to address following scenario.
95
	/* Reset reach mode, to address following scenario.
77
	 *   final blank;
96
	 *   final blank;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (+3 lines)
Lines 76-81 Link Here
76
						this.arguments[i]
76
						this.arguments[i]
77
							.analyseCode(currentScope, flowContext, flowInfo)
77
							.analyseCode(currentScope, flowContext, flowInfo)
78
							.unconditionalInits();
78
							.unconditionalInits();
79
					if ((this.arguments[i].implicitConversion & TypeIds.UNBOXING) != 0) {
80
						this.arguments[i].checkNPE(currentScope, flowContext, flowInfo);
81
					}
79
				}
82
				}
80
			}
83
			}
81
84
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java (+3 lines)
Lines 92-97 Link Here
92
							new LoopingFlowContext(flowContext, flowInfo, this, null,
92
							new LoopingFlowContext(flowContext, flowInfo, this, null,
93
								null, this.scope)),
93
								null, this.scope)),
94
						condInfo);
94
						condInfo);
95
				if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
96
					this.condition.checkNPE(currentScope, flowContext, flowInfo);
97
				}
95
			}
98
			}
96
		}
99
		}
97
100
(-)compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java (+3 lines)
Lines 57-62 Link Here
57
	int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;
57
	int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;
58
58
59
	Constant cst = this.condition.optimizedBooleanConstant();
59
	Constant cst = this.condition.optimizedBooleanConstant();
60
	if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
61
		this.condition.checkNPE(currentScope, flowContext, flowInfo);
62
	}
60
	boolean isConditionOptimizedTrue = cst != Constant.NotAConstant && cst.booleanValue() == true;
63
	boolean isConditionOptimizedTrue = cst != Constant.NotAConstant && cst.booleanValue() == true;
61
	boolean isConditionOptimizedFalse = cst != Constant.NotAConstant && cst.booleanValue() == false;
64
	boolean isConditionOptimizedFalse = cst != Constant.NotAConstant && cst.booleanValue() == false;
62
65
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java (+3 lines)
Lines 40-45 Link Here
40
	if (this.initialization == null) {
40
	if (this.initialization == null) {
41
		return flowInfo;
41
		return flowInfo;
42
	}
42
	}
43
	if ((this.initialization.implicitConversion & TypeIds.UNBOXING) != 0) {
44
		this.initialization.checkNPE(currentScope, flowContext, flowInfo);
45
	}
43
	int nullStatus = this.initialization.nullStatus(flowInfo);
46
	int nullStatus = this.initialization.nullStatus(flowInfo);
44
	flowInfo =
47
	flowInfo =
45
		this.initialization
48
		this.initialization
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (+3 lines)
Lines 65-70 Link Here
65
	if (this.arguments != null) {
65
	if (this.arguments != null) {
66
		int length = this.arguments.length;
66
		int length = this.arguments.length;
67
		for (int i = 0; i < length; i++) {
67
		for (int i = 0; i < length; i++) {
68
			if ((this.arguments[i].implicitConversion & TypeIds.UNBOXING) != 0) {
69
				this.arguments[i].checkNPE(currentScope, flowContext, flowInfo);
70
			}
68
			flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
71
			flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
69
		}
72
		}
70
	}
73
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java (+6 lines)
Lines 62-67 Link Here
62
			}
62
			}
63
		}
63
		}
64
		rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo);
64
		rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo);
65
		if ((this.left.implicitConversion & TypeIds.UNBOXING) != 0) {
66
			this.left.checkNPE(currentScope, flowContext, flowInfo);
67
		}
68
		if ((this.right.implicitConversion & TypeIds.UNBOXING) != 0) {
69
			this.right.checkNPE(currentScope, flowContext, flowInfo);
70
		}
65
		// The definitely null variables in right info when true should not be missed out while merging
71
		// The definitely null variables in right info when true should not be missed out while merging
66
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900
72
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900
67
		FlowInfo leftInfoWhenTrueForMerging = leftInfo.initsWhenTrue().unconditionalCopy().addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect());
73
		FlowInfo leftInfoWhenTrueForMerging = leftInfo.initsWhenTrue().unconditionalCopy().addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect());
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (+3 lines)
Lines 71-76 Link Here
71
		if (this.arguments != null) {
71
		if (this.arguments != null) {
72
			for (int i = 0, count = this.arguments.length; i < count; i++) {
72
			for (int i = 0, count = this.arguments.length; i < count; i++) {
73
				flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo);
73
				flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo);
74
				if ((this.arguments[i].implicitConversion & TypeIds.UNBOXING) != 0) {
75
					this.arguments[i].checkNPE(currentScope, flowContext, flowInfo);
76
				}
74
			}
77
			}
75
		}
78
		}
76
79
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java (+3 lines)
Lines 36-41 Link Here
36
36
37
	if (this.expression != null) {
37
	if (this.expression != null) {
38
		flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
38
		flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
39
		if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) {
40
			this.expression.checkNPE(currentScope, flowContext, flowInfo);
41
		}
39
	}
42
	}
40
	this.initStateIndex =
43
	this.initStateIndex =
41
		currentScope.methodScope().recordInitializationStates(flowInfo);
44
		currentScope.methodScope().recordInitializationStates(flowInfo);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (+3 lines)
Lines 47-52 Link Here
47
	public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
47
	public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
48
		try {
48
		try {
49
			flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
49
			flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
50
			if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) {
51
				this.expression.checkNPE(currentScope, flowContext, flowInfo);
52
			}
50
			SwitchFlowContext switchContext =
53
			SwitchFlowContext switchContext =
51
				new SwitchFlowContext(flowContext, this, (this.breakLabel = new BranchLabel()));
54
				new SwitchFlowContext(flowContext, this, (this.breakLabel = new BranchLabel()));
52
55
(-)compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java (+3 lines)
Lines 63-68 Link Here
63
					new LoopingFlowContext(flowContext, flowInfo, this, null,
63
					new LoopingFlowContext(flowContext, flowInfo, this, null,
64
						null, currentScope)),
64
						null, currentScope)),
65
				condInfo);
65
				condInfo);
66
		if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
67
			this.condition.checkNPE(currentScope, flowContext, flowInfo);
68
		}
66
69
67
		LoopingFlowContext loopingContext;
70
		LoopingFlowContext loopingContext;
68
		FlowInfo actionInfo;
71
		FlowInfo actionInfo;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (+265 lines)
Lines 11715-11718 Link Here
11715
		"    24  return\n";
11715
		"    24  return\n";
11716
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
11716
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
11717
}
11717
}
11718
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
11719
// unboxing raises an NPE
11720
//   LocalDeclaration
11721
public void testBug319201() {
11722
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
11723
		return;
11724
	runNegativeTest(
11725
			new String[] {
11726
				"X.java",
11727
				"public class X {\n" +
11728
				"  public void foo() {\n" +
11729
				"	 Integer i = null;\n" +
11730
				"	 int j = i;\n" + // should warn
11731
				"  }\n" +
11732
				"}"},
11733
			"----------\n" + 
11734
			"1. ERROR in X.java (at line 4)\n" + 
11735
			"	int j = i;\n" + 
11736
			"	        ^\n" + 
11737
			"Null pointer access: The variable i can only be null at this location\n" + 
11738
			"----------\n",
11739
		    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
11740
}
11741
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
11742
// unboxing could raise an NPE
11743
//   Assignment
11744
public void testBug319201a() {
11745
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
11746
		return;
11747
	runNegativeTest(
11748
			new String[] {
11749
				"X.java",
11750
				"public class X {\n" +
11751
				"  public void foo(Integer i) {\n" +
11752
				"    if (i == null) {};\n" +
11753
				"	 int j;\n" +
11754
				"	 j = i;\n" + // should warn
11755
				"  }\n" +
11756
				"}"},
11757
			"----------\n" + 
11758
			"1. ERROR in X.java (at line 5)\n" + 
11759
			"	j = i;\n" + 
11760
			"	    ^\n" + 
11761
			"Potential null pointer access: The variable i may be null at this location\n" + 
11762
			"----------\n",
11763
		    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
11764
}
11765
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
11766
// unboxing raises an NPE
11767
//   MessageSend
11768
public void testBug319201b() {
11769
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
11770
		return;
11771
	runNegativeTest(
11772
			new String[] {
11773
				"X.java",
11774
				"public class X {\n" +
11775
				"  public void foo() {\n" +
11776
				"    Boolean bo = null;;\n" +
11777
				"	 bar(bo);\n" + // should warn
11778
				"  }\n" +
11779
				"  void bar(boolean b) {}\n" +
11780
				"}"},
11781
			"----------\n" + 
11782
			"1. ERROR in X.java (at line 4)\n" + 
11783
			"	bar(bo);\n" + 
11784
			"	    ^^\n" + 
11785
			"Null pointer access: The variable bo can only be null at this location\n" + 
11786
			"----------\n",
11787
		    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
11788
}
11789
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
11790
// unboxing raises an NPE
11791
// Node types covered (in this order):
11792
//   ExplicitConstructorCall
11793
//   AllocationExpression
11794
//   AND_AND_Expression
11795
//   OR_OR_Expression
11796
//   ArrayAllocationExpression
11797
//   ForStatement
11798
//   DoStatement
11799
//   IfStatement
11800
//   QualifiedAllocationExpression
11801
//   SwitchStatement
11802
//   WhileStatement
11803
//   CastExpression
11804
//   AssertStatement
11805
//   ReturnStatement
11806
public void testBug319201c() {
11807
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
11808
		return;
11809
	runNegativeTest(
11810
			new String[] {
11811
              "X.java",
11812
              "class Y { public Y(boolean b1, boolean b2) {} }\n" +
11813
              "public class X extends Y {\n" +
11814
              "  public X(boolean b, Boolean b2) {\n" +
11815
              "      super(b2 == null, b2);\n" +
11816
              "  }\n" +
11817
              "  class Z {\n" +
11818
              "      public Z(boolean b) {}\n" +
11819
              "  }\n" +
11820
              "  boolean fB = (Boolean)null;\n" +
11821
              "  public boolean foo(boolean inB) {\n" +
11822
              "      Boolean b1 = null;\n" +
11823
              "      X x = new X(b1, null);\n" +
11824
              "      Boolean b2 = null;\n" +
11825
              "      boolean dontcare = b2 && inB;\n" +
11826
              "      Boolean b3 = null;\n" +
11827
              "      dontcare = inB || b3;\n" +
11828
              "      Integer dims = null;\n" +
11829
              "      char[] cs = new char[dims];\n" +
11830
              "      Boolean b5 = null;\n" +
11831
              "      do {\n" +
11832
              "          Boolean b4 = null;\n" +
11833
              "          for (int i=0;b4; i++);\n" +
11834
              "      } while (b5);\n" +
11835
              "      Boolean b6 = null;\n" +
11836
              "      if (b6) { }\n" +
11837
              "      Boolean b7 = null;\n" +
11838
              "      Z z = this.new Z(b7);\n" +
11839
              "      Integer sel = null;\n" +
11840
              "      switch(sel) {\n" +
11841
              "          case 1: break;\n" +
11842
              "          default: break;\n" +
11843
              "      }\n" +
11844
              "      Boolean b8 = null;\n" +
11845
              "      while (b8) {}\n" +
11846
              "      Boolean b9 = null;\n" +
11847
              "      dontcare = (boolean)b9;\n" +
11848
              "      Boolean b10 = null;\n" +
11849
              "      assert b10 : \"shouldn't happen, but will\";\n" +
11850
              "      Boolean b11 = null;\n" +
11851
              "      return b11;\n" +
11852
              "  }\n" +
11853
				"}"},
11854
			"----------\n" + 
11855
			"1. ERROR in X.java (at line 4)\n" + 
11856
			"	super(b2 == null, b2);\n" + 
11857
			"	                  ^^\n" + 
11858
			"Potential null pointer access: The variable b2 may be null at this location\n" + 
11859
			"----------\n" + 
11860
			"2. ERROR in X.java (at line 12)\n" + 
11861
			"	X x = new X(b1, null);\n" + 
11862
			"	            ^^\n" + 
11863
			"Null pointer access: The variable b1 can only be null at this location\n" + 
11864
			"----------\n" + 
11865
			"3. ERROR in X.java (at line 14)\n" + 
11866
			"	boolean dontcare = b2 && inB;\n" + 
11867
			"	                   ^^\n" + 
11868
			"Null pointer access: The variable b2 can only be null at this location\n" + 
11869
			"----------\n" + 
11870
			"4. ERROR in X.java (at line 16)\n" + 
11871
			"	dontcare = inB || b3;\n" + 
11872
			"	                  ^^\n" + 
11873
			"Null pointer access: The variable b3 can only be null at this location\n" + 
11874
			"----------\n" + 
11875
			"5. ERROR in X.java (at line 18)\n" + 
11876
			"	char[] cs = new char[dims];\n" + 
11877
			"	                     ^^^^\n" + 
11878
			"Null pointer access: The variable dims can only be null at this location\n" + 
11879
			"----------\n" + 
11880
			"6. ERROR in X.java (at line 22)\n" + 
11881
			"	for (int i=0;b4; i++);\n" + 
11882
			"	             ^^\n" + 
11883
			"Null pointer access: The variable b4 can only be null at this location\n" + 
11884
			"----------\n" + 
11885
			"7. ERROR in X.java (at line 23)\n" + 
11886
			"	} while (b5);\n" + 
11887
			"	         ^^\n" + 
11888
			"Null pointer access: The variable b5 can only be null at this location\n" + 
11889
			"----------\n" + 
11890
			"8. ERROR in X.java (at line 25)\n" + 
11891
			"	if (b6) { }\n" + 
11892
			"	    ^^\n" + 
11893
			"Null pointer access: The variable b6 can only be null at this location\n" + 
11894
			"----------\n" + 
11895
			"9. ERROR in X.java (at line 27)\n" + 
11896
			"	Z z = this.new Z(b7);\n" + 
11897
			"	                 ^^\n" + 
11898
			"Null pointer access: The variable b7 can only be null at this location\n" + 
11899
			"----------\n" + 
11900
			"10. ERROR in X.java (at line 29)\n" + 
11901
			"	switch(sel) {\n" + 
11902
			"	       ^^^\n" + 
11903
			"Null pointer access: The variable sel can only be null at this location\n" + 
11904
			"----------\n" + 
11905
			"11. ERROR in X.java (at line 34)\n" + 
11906
			"	while (b8) {}\n" + 
11907
			"	       ^^\n" + 
11908
			"Null pointer access: The variable b8 can only be null at this location\n" + 
11909
			"----------\n" + 
11910
			"12. ERROR in X.java (at line 36)\n" + 
11911
			"	dontcare = (boolean)b9;\n" + 
11912
			"	                    ^^\n" + 
11913
			"Null pointer access: The variable b9 can only be null at this location\n" + 
11914
			"----------\n" + 
11915
			"13. ERROR in X.java (at line 38)\n" + 
11916
			"	assert b10 : \"shouldn\'t happen, but will\";\n" + 
11917
			"	       ^^^\n" + 
11918
			"Null pointer access: The variable b10 can only be null at this location\n" + 
11919
			"----------\n" + 
11920
			"14. ERROR in X.java (at line 40)\n" + 
11921
			"	return b11;\n" + 
11922
			"	       ^^^\n" + 
11923
			"Null pointer access: The variable b11 can only be null at this location\n" + 
11924
			"----------\n",
11925
		    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
11926
}
11927
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
11928
// unboxing raises an NPE
11929
// DoStatement, variants with assignement in the body & empty body
11930
public void testBug319201d() {
11931
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
11932
		return;
11933
	runNegativeTest(
11934
			new String[] {
11935
              "X.java",
11936
              "public class X {\n" +
11937
              "  public void foo(boolean cond, boolean cond2) {\n" +
11938
              "      Boolean b = null;\n" +
11939
              "      do {\n" +
11940
              "          b = false;\n" +
11941
              "          if (cond) continue;\n" +   // shouldn't make a difference
11942
              "      } while (b);\n" + // don't complain, loop body has already assigned b
11943
              "      Boolean b2 = null;\n" +
11944
              "      do {\n" +
11945
              "          if (cond) continue;\n" +
11946
              "          b2 = false;\n" +
11947
              "      } while (b2);\n" + // complain here: potentially null
11948
              "      Boolean b3 = null;\n" +
11949
              "      do {\n" +
11950
              "      } while (b3);\n" + // complain here: definitely null
11951
              "      Boolean b4 = null;\n" +
11952
              "      do {\n" +
11953
              "        if (cond) {\n" +
11954
              "            b4 = true;\n" +
11955
              "            if (cond2) continue;\n" +
11956
              "        }\n" +
11957
              "        b4 = false;\n" +
11958
              "      } while (b4);\n" + // don't complain here: definitely non-null
11959
              "      Boolean b5 = null;\n" +
11960
              "      do {\n" +
11961
              "         b5 = true;\n" +
11962
              "      } while (b5);\n" +  // don't complain 
11963
              "      Boolean b6 = null;\n" +
11964
              "      do {\n" +
11965
              "         b6 = true;\n" +
11966
              "         continue;\n" +
11967
              "      } while (b6); \n" + // don't complain
11968
              "  }\n" +
11969
			  "}"},
11970
			"----------\n" + 
11971
			"1. ERROR in X.java (at line 12)\n" + 
11972
			"	} while (b2);\n" + 
11973
			"	         ^^\n" + 
11974
			"Potential null pointer access: The variable b2 may be null at this location\n" + 
11975
			"----------\n" + 
11976
			"2. ERROR in X.java (at line 15)\n" + 
11977
			"	} while (b3);\n" + 
11978
			"	         ^^\n" + 
11979
			"Null pointer access: The variable b3 can only be null at this location\n" + 
11980
			"----------\n",
11981
		    JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
11982
}
11718
}
11983
}

Return to bug 319201