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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (-2 / +8 lines)
Lines 39-50 Link Here
39
				if (((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
39
				if (((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
40
					flowContext.recordUsingNullReference(scope, local, reference, 
40
					flowContext.recordUsingNullReference(scope, local, reference, 
41
							FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NULL, flowInfo);
41
							FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NULL, flowInfo);
42
					initsWhenTrue.markAsComparedEqualToNull(local); // from thereon it is set
42
					if (flowInfo.isDefinitelyNonNull(local))
43
						this.constant = BooleanConstant.fromValue(false);
44
					else
45
						initsWhenTrue.markAsComparedEqualToNull(local); // from thereon it is set
43
					initsWhenFalse.markAsComparedEqualToNonNull(local); // from thereon it is set
46
					initsWhenFalse.markAsComparedEqualToNonNull(local); // from thereon it is set
44
				} else {
47
				} else {
45
					flowContext.recordUsingNullReference(scope, local, reference, 
48
					flowContext.recordUsingNullReference(scope, local, reference, 
46
							FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NON_NULL, flowInfo);
49
							FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NON_NULL, flowInfo);
47
					initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
50
					if (flowInfo.isDefinitelyNull(local))
51
						this.constant = BooleanConstant.fromValue(false);
52
					else
53
						initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
48
					initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set
54
					initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set
49
				}
55
				}
50
				break;
56
				break;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (-17 / +12 lines)
Lines 1794-1803 Link Here
1794
		"	    ^\n" + 
1794
		"	    ^\n" + 
1795
		"Null comparison always yields false: The variable o cannot be null at this location\n" + 
1795
		"Null comparison always yields false: The variable o cannot be null at this location\n" + 
1796
		"----------\n" + 
1796
		"----------\n" + 
1797
		"2. ERROR in X.java (at line 7)\n" + 
1797
		"2. ERROR in X.java (at line 6)\n" + 
1798
		"	o.toString();\n" + 
1798
		"	if (o != null) { /* */ }\n" + 
1799
		"	^\n" + 
1799
		"	    ^\n" + 
1800
		"Potential null pointer access: The variable o may be null at this location\n" + 
1800
		"Redundant null check: The variable o cannot be null at this location\n" + 
1801
		"----------\n");
1801
		"----------\n");
1802
}
1802
}
1803
 
1803
 
Lines 7360-7366 Link Here
7360
		"2. ERROR in X.java (at line 5)\n" + 
7360
		"2. ERROR in X.java (at line 5)\n" + 
7361
		"	if (o == null) { };\n" + 
7361
		"	if (o == null) { };\n" + 
7362
		"	    ^\n" + 
7362
		"	    ^\n" + 
7363
		"Null comparison always yields false: The variable o cannot be null at this location\n" + 
7363
		"Redundant null check: The variable o can only be null at this location\n" + 
7364
		"----------\n");
7364
		"----------\n");
7365
	}
7365
	}
7366
}
7366
}
Lines 7528-7544 Link Here
7528
		"	    ^\n" + 
7528
		"	    ^\n" + 
7529
		"Null comparison always yields false: The variable x cannot be null at this location\n" + 
7529
		"Null comparison always yields false: The variable x cannot be null at this location\n" + 
7530
		"----------\n" + 
7530
		"----------\n" + 
7531
		"3. ERROR in X.java (at line 6)\n" + 
7531
		"3. ERROR in X.java (at line 9)\n" + 
7532
		"	x.foo(null); // 3\n" + 
7533
		"	^\n" + 
7534
		"Null pointer access: The variable x can only be null at this location\n" + 
7535
		"----------\n" + 
7536
		"4. ERROR in X.java (at line 9)\n" + 
7537
		"	} else if (x != null) { // 6\n" + 
7532
		"	} else if (x != null) { // 6\n" + 
7538
		"	           ^\n" + 
7533
		"	           ^\n" + 
7539
		"Redundant null check: The variable x cannot be null at this location\n" + 
7534
		"Redundant null check: The variable x cannot be null at this location\n" + 
7540
		"----------\n" + 
7535
		"----------\n" + 
7541
		"5. ERROR in X.java (at line 12)\n" + 
7536
		"4. ERROR in X.java (at line 12)\n" + 
7542
		"	x.foo(null); // 8\n" + 
7537
		"	x.foo(null); // 8\n" + 
7543
		"	^\n" + 
7538
		"	^\n" + 
7544
		"Potential null pointer access: The variable x may be null at this location\n" + 
7539
		"Potential null pointer access: The variable x may be null at this location\n" + 
Lines 7744-7754 Link Here
7744
		"	if (x == null) {\n" + 
7739
		"	if (x == null) {\n" + 
7745
		"	    ^\n" + 
7740
		"	    ^\n" + 
7746
		"Null comparison always yields false: The variable x cannot be null at this location\n" + 
7741
		"Null comparison always yields false: The variable x cannot be null at this location\n" + 
7747
		"----------\n" + 
7748
		"2. ERROR in X.java (at line 5)\n" + 
7749
		"	x.foo(this);\n" + 
7750
		"	^\n" + 
7751
		"Null pointer access: The variable x can only be null at this location\n" + 
7752
		"----------\n");
7742
		"----------\n");
7753
}
7743
}
7754
7744
Lines 8774-8779 Link Here
8774
		"	if (o65 == null) { /* */ }\n" + 
8764
		"	if (o65 == null) { /* */ }\n" + 
8775
		"	    ^^^\n" + 
8765
		"	    ^^^\n" + 
8776
		"Null comparison always yields false: The variable o65 cannot be null at this location\n" +  
8766
		"Null comparison always yields false: The variable o65 cannot be null at this location\n" +  
8767
		"----------\n" + 
8768
		"2. ERROR in X.java (at line 19)\n" + 
8769
		"	if (o65 != null) { /* */ }\n" + 
8770
		"	    ^^^\n" + 
8771
		"Redundant null check: The variable o65 cannot be null at this location\n" + 
8777
		"----------\n");
8772
		"----------\n");
8778
}
8773
}
8779
8774

Return to bug 190623