View | Details | Raw Unified | Return to bug 303810
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 45-53 Link Here
45
	boolean isOptimizedTrueAssertion = cst != Constant.NotAConstant && cst.booleanValue() == true;
45
	boolean isOptimizedTrueAssertion = cst != Constant.NotAConstant && cst.booleanValue() == true;
46
	boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
46
	boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
47
	
47
	
48
	flowContext.hideNullComparisonWarnings = true;
48
	flowContext.tagBits |= FlowContext.HIDE_NULL_COMPARISON_WARNING;
49
	FlowInfo conditionFlowInfo = this.assertExpression.analyseCode(currentScope, flowContext, flowInfo.copy());
49
	FlowInfo conditionFlowInfo = this.assertExpression.analyseCode(currentScope, flowContext, flowInfo.copy());
50
	flowContext.hideNullComparisonWarnings = false;
50
	flowContext.tagBits &= ~FlowContext.HIDE_NULL_COMPARISON_WARNING;
51
	UnconditionalFlowInfo assertWhenTrueInfo = conditionFlowInfo.initsWhenTrue().unconditionalInits();
51
	UnconditionalFlowInfo assertWhenTrueInfo = conditionFlowInfo.initsWhenTrue().unconditionalInits();
52
	FlowInfo assertInfo = conditionFlowInfo.initsWhenFalse();
52
	FlowInfo assertInfo = conditionFlowInfo.initsWhenFalse();
53
	if (isOptimizedTrueAssertion) {
53
	if (isOptimizedTrueAssertion) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (-1 / +1 lines)
Lines 47-53 Link Here
47
					initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
47
					initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set
48
					initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set
48
					initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set
49
				}
49
				}
50
				if (flowContext.hideNullComparisonWarnings) {
50
				if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) {
51
					flowInfo.markedAsNullOrNonNullInAssertExpression(local);
51
					flowInfo.markedAsNullOrNonNullInAssertExpression(local);
52
				}
52
				}
53
				break;
53
				break;
(-)compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java (-15 / +15 lines)
Lines 81-87 Link Here
81
	}
81
	}
82
82
83
	// check inconsistent null checks
83
	// check inconsistent null checks
84
	if (this.deferNullDiagnostic) { // within an enclosing loop, be conservative
84
	if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { // within an enclosing loop, be conservative
85
		for (int i = 0; i < this.nullCount; i++) {
85
		for (int i = 0; i < this.nullCount; i++) {
86
			this.parent.recordUsingNullReference(scope, this.nullLocals[i],
86
			this.parent.recordUsingNullReference(scope, this.nullLocals[i],
87
					this.nullReferences[i],	this.nullCheckTypes[i], flowInfo);
87
					this.nullReferences[i],	this.nullCheckTypes[i], flowInfo);
Lines 97-107 Link Here
97
				case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
97
				case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
98
					if (flowInfo.isDefinitelyNonNull(local)) {
98
					if (flowInfo.isDefinitelyNonNull(local)) {
99
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
99
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
100
							if (!this.hideNullComparisonWarnings) {
100
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
101
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
101
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
102
							}
102
							}
103
						} else {
103
						} else {
104
							if (!this.hideNullComparisonWarnings) {
104
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
105
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
105
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
106
							}
106
							}
107
						}
107
						}
Lines 119-125 Link Here
119
									scope.problemReporter().localVariableNullReference(local, expression);
119
									scope.problemReporter().localVariableNullReference(local, expression);
120
									continue;
120
									continue;
121
								}
121
								}
122
								if (!this.hideNullComparisonWarnings) {
122
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
123
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
123
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
124
								}
124
								}
125
								continue;
125
								continue;
Lines 128-134 Link Here
128
									scope.problemReporter().localVariableNullReference(local, expression);
128
									scope.problemReporter().localVariableNullReference(local, expression);
129
									continue;
129
									continue;
130
								}
130
								}
131
								if (!this.hideNullComparisonWarnings) {
131
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
132
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
132
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
133
								}
133
								}
134
								continue;
134
								continue;
Lines 215-221 Link Here
215
	public void recordUsingNullReference(Scope scope, LocalVariableBinding local,
215
	public void recordUsingNullReference(Scope scope, LocalVariableBinding local,
216
			Expression reference, int checkType, FlowInfo flowInfo) {
216
			Expression reference, int checkType, FlowInfo flowInfo) {
217
		if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0 && !flowInfo.isDefinitelyUnknown(local))	{
217
		if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0 && !flowInfo.isDefinitelyUnknown(local))	{
218
			if (this.deferNullDiagnostic) { // within an enclosing loop, be conservative
218
			if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { // within an enclosing loop, be conservative
219
				switch (checkType) {
219
				switch (checkType) {
220
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
220
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL:
221
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
221
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
Lines 225-238 Link Here
225
					case CAN_ONLY_NULL | IN_INSTANCEOF:
225
					case CAN_ONLY_NULL | IN_INSTANCEOF:
226
						if (flowInfo.cannotBeNull(local)) {
226
						if (flowInfo.cannotBeNull(local)) {
227
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
227
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
228
								if (!this.hideNullComparisonWarnings) {
228
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
229
									scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
229
									scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
230
								}
230
								}
231
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
231
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
232
									flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
232
									flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
233
								}
233
								}
234
							} else if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
234
							} else if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
235
								if (!this.hideNullComparisonWarnings) {
235
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
236
									scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
236
									scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
237
								}
237
								}
238
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
238
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 248-254 Link Here
248
										scope.problemReporter().localVariableNullReference(local, reference);
248
										scope.problemReporter().localVariableNullReference(local, reference);
249
										return;
249
										return;
250
									}
250
									}
251
									if (!this.hideNullComparisonWarnings) {
251
									if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
252
										scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
252
										scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
253
									}
253
									}
254
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
254
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 260-266 Link Here
260
										scope.problemReporter().localVariableNullReference(local, reference);
260
										scope.problemReporter().localVariableNullReference(local, reference);
261
										return;
261
										return;
262
									}
262
									}
263
									if (!this.hideNullComparisonWarnings) {
263
									if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
264
										scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
264
										scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
265
									}
265
									}
266
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
266
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 310-323 Link Here
310
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
310
					case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
311
						if (flowInfo.isDefinitelyNonNull(local)) {
311
						if (flowInfo.isDefinitelyNonNull(local)) {
312
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
312
							if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
313
								if (!this.hideNullComparisonWarnings) {
313
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
314
									scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
314
									scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
315
								}
315
								}
316
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
316
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
317
									flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
317
									flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
318
								}
318
								}
319
							} else {
319
							} else {
320
								if (!this.hideNullComparisonWarnings) {
320
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
321
									scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
321
									scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
322
								}
322
								}
323
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
323
								if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 338-344 Link Here
338
										scope.problemReporter().localVariableNullReference(local, reference);
338
										scope.problemReporter().localVariableNullReference(local, reference);
339
										return;
339
										return;
340
									}
340
									}
341
									if (!this.hideNullComparisonWarnings) {
341
									if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
342
										scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
342
										scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
343
									}
343
									}
344
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
344
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 350-356 Link Here
350
										scope.problemReporter().localVariableNullReference(local, reference);
350
										scope.problemReporter().localVariableNullReference(local, reference);
351
										return;
351
										return;
352
									}
352
									}
353
									if (!this.hideNullComparisonWarnings) {
353
									if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
354
										scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
354
										scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
355
									}
355
									}
356
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
356
									if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 400-406 Link Here
400
			}
400
			}
401
			// if the contention is inside assert statement, we want to avoid null warnings only in case of
401
			// if the contention is inside assert statement, we want to avoid null warnings only in case of
402
			// comparisons and not in case of assignment, instanceof, or may be null.
402
			// comparisons and not in case of assignment, instanceof, or may be null.
403
			if(!this.hideNullComparisonWarnings || checkType == MAY_NULL
403
			if(((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) || checkType == MAY_NULL
404
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_ASSIGNMENT
404
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_ASSIGNMENT
405
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_INSTANCEOF) {
405
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_INSTANCEOF) {
406
				recordNullReference(local, reference, checkType);
406
				recordNullReference(local, reference, checkType);
(-)compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java (-11 / +14 lines)
Lines 44-54 Link Here
44
		// only used within try blocks; remembers upstream flow info mergedWith
44
		// only used within try blocks; remembers upstream flow info mergedWith
45
		// any null related operation happening within the try block
45
		// any null related operation happening within the try block
46
46
47
boolean deferNullDiagnostic, preemptNullDiagnostic;
47
	public int tagBits;
48
/**
48
	public static final int DEFER_NULL_DIAGNOSTIC = 0x1;
49
 * used to hide null comparison related warnings inside assert statements 
49
	public static final int PREEMPT_NULL_DIAGNOSTIC = 0x2;
50
 */
50
	/**
51
public boolean hideNullComparisonWarnings = false;
51
	 * used to hide null comparison related warnings inside assert statements 
52
	 */
53
	public static final int HIDE_NULL_COMPARISON_WARNING = 0x4;
52
54
53
public static final int CAN_ONLY_NULL_NON_NULL = 0x0000;
55
public static final int CAN_ONLY_NULL_NON_NULL = 0x0000;
54
//check against null and non null, with definite values -- comparisons
56
//check against null and non null, with definite values -- comparisons
Lines 72-79 Link Here
72
	this.parent = parent;
74
	this.parent = parent;
73
	this.associatedNode = associatedNode;
75
	this.associatedNode = associatedNode;
74
	if (parent != null) {
76
	if (parent != null) {
75
		this.deferNullDiagnostic =
77
		if ((parent.tagBits & (FlowContext.DEFER_NULL_DIAGNOSTIC | FlowContext.PREEMPT_NULL_DIAGNOSTIC)) != 0) {
76
			parent.deferNullDiagnostic || parent.preemptNullDiagnostic;
78
			this.tagBits |= FlowContext.DEFER_NULL_DIAGNOSTIC;
79
		}
77
		this.initsOnFinally = parent.initsOnFinally;
80
		this.initsOnFinally = parent.initsOnFinally;
78
	}
81
	}
79
}
82
}
Lines 546-559 Link Here
546
		case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
549
		case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
547
			if (flowInfo.isDefinitelyNonNull(local)) {
550
			if (flowInfo.isDefinitelyNonNull(local)) {
548
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
551
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
549
					if (!this.hideNullComparisonWarnings) {
552
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
550
						scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
553
						scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
551
					}
554
					}
552
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
555
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
553
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
556
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
554
					}
557
					}
555
				} else {
558
				} else {
556
					if (!this.hideNullComparisonWarnings) {
559
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
557
						scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
560
						scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
558
					}
561
					}
559
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
562
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 577-583 Link Here
577
							scope.problemReporter().localVariableNullReference(local, reference);
580
							scope.problemReporter().localVariableNullReference(local, reference);
578
							return;
581
							return;
579
						}
582
						}
580
						if (!this.hideNullComparisonWarnings) {
583
						if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
581
							scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
584
							scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
582
						}
585
						}
583
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
586
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 589-595 Link Here
589
							scope.problemReporter().localVariableNullReference(local, reference);
592
							scope.problemReporter().localVariableNullReference(local, reference);
590
							return;
593
							return;
591
						}
594
						}
592
						if (!this.hideNullComparisonWarnings) {
595
						if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
593
							scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
596
							scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
594
						}
597
						}
595
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
598
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
(-)compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java (-23 / +23 lines)
Lines 55-61 Link Here
55
		BranchLabel continueLabel,
55
		BranchLabel continueLabel,
56
		Scope associatedScope) {
56
		Scope associatedScope) {
57
		super(parent, associatedNode, breakLabel);
57
		super(parent, associatedNode, breakLabel);
58
		this.preemptNullDiagnostic = true;
58
		this.tagBits |= FlowContext.PREEMPT_NULL_DIAGNOSTIC;
59
			// children will defer to this, which may defer to its own parent
59
			// children will defer to this, which may defer to its own parent
60
		this.continueLabel = continueLabel;
60
		this.continueLabel = continueLabel;
61
		this.associatedScope = associatedScope;
61
		this.associatedScope = associatedScope;
Lines 116-122 Link Here
116
	this.innerFlowContextsCount = 0;
116
	this.innerFlowContextsCount = 0;
117
	UnconditionalFlowInfo flowInfo = this.upstreamNullFlowInfo.
117
	UnconditionalFlowInfo flowInfo = this.upstreamNullFlowInfo.
118
		addPotentialNullInfoFrom(callerFlowInfo.unconditionalInitsWithoutSideEffect());
118
		addPotentialNullInfoFrom(callerFlowInfo.unconditionalInitsWithoutSideEffect());
119
	if (this.deferNullDiagnostic) {
119
	if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) {
120
		// check only immutable null checks on innermost looping context
120
		// check only immutable null checks on innermost looping context
121
		for (int i = 0; i < this.nullCount; i++) {
121
		for (int i = 0; i < this.nullCount; i++) {
122
			LocalVariableBinding local = this.nullLocals[i];
122
			LocalVariableBinding local = this.nullLocals[i];
Lines 128-138 Link Here
128
					if (flowInfo.isDefinitelyNonNull(local)) {
128
					if (flowInfo.isDefinitelyNonNull(local)) {
129
						this.nullReferences[i] = null;
129
						this.nullReferences[i] = null;
130
						if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) {
130
						if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) {
131
							if (!this.hideNullComparisonWarnings) {
131
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
132
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
132
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
133
							}
133
							}
134
						} else {
134
						} else {
135
							if (!this.hideNullComparisonWarnings) {
135
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
136
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
136
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
137
							}
137
							}
138
						}
138
						}
Lines 144-154 Link Here
144
					if (flowInfo.isDefinitelyNonNull(local)) {
144
					if (flowInfo.isDefinitelyNonNull(local)) {
145
						this.nullReferences[i] = null;
145
						this.nullReferences[i] = null;
146
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
146
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
147
							if (!this.hideNullComparisonWarnings) {
147
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
148
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
148
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
149
							}
149
							}
150
						} else {
150
						} else {
151
							if (!this.hideNullComparisonWarnings) {
151
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
152
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
152
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
153
							}
153
							}
154
						}
154
						}
Lines 157-167 Link Here
157
					if (flowInfo.isDefinitelyNull(local)) {
157
					if (flowInfo.isDefinitelyNull(local)) {
158
						this.nullReferences[i] = null;
158
						this.nullReferences[i] = null;
159
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
159
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
160
							if (!this.hideNullComparisonWarnings) {
160
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
161
								scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
161
								scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
162
							}
162
							}
163
						} else {
163
						} else {
164
							if (!this.hideNullComparisonWarnings) {
164
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
165
								scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
165
								scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
166
							}
166
							}
167
						}
167
						}
Lines 180-186 Link Here
180
									scope.problemReporter().localVariableNullReference(local, expression);
180
									scope.problemReporter().localVariableNullReference(local, expression);
181
									continue;
181
									continue;
182
								}
182
								}
183
								if (!this.hideNullComparisonWarnings) {
183
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
184
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
184
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
185
								}
185
								}
186
								continue;
186
								continue;
Lines 189-195 Link Here
189
									scope.problemReporter().localVariableNullReference(local, expression);
189
									scope.problemReporter().localVariableNullReference(local, expression);
190
									continue;
190
									continue;
191
								}
191
								}
192
								if (!this.hideNullComparisonWarnings) {
192
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
193
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
193
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
194
								}
194
								}
195
								continue;
195
								continue;
Lines 245-255 Link Here
245
					if (flowInfo.isDefinitelyNonNull(local)) {
245
					if (flowInfo.isDefinitelyNonNull(local)) {
246
						this.nullReferences[i] = null;
246
						this.nullReferences[i] = null;
247
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
247
						if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
248
							if (!this.hideNullComparisonWarnings) {
248
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
249
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
249
								scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression);
250
							}
250
							}
251
						} else {
251
						} else {
252
							if (!this.hideNullComparisonWarnings) {
252
							if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
253
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
253
								scope.problemReporter().localVariableNonNullComparedToNull(local, expression);
254
							}
254
							}
255
						}
255
						}
Lines 268-274 Link Here
268
									scope.problemReporter().localVariableNullReference(local, expression);
268
									scope.problemReporter().localVariableNullReference(local, expression);
269
									continue;
269
									continue;
270
								}
270
								}
271
								if (!this.hideNullComparisonWarnings) {
271
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
272
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
272
									scope.problemReporter().localVariableRedundantCheckOnNull(local, expression);
273
								}
273
								}
274
								continue;
274
								continue;
Lines 277-283 Link Here
277
									scope.problemReporter().localVariableNullReference(local, expression);
277
									scope.problemReporter().localVariableNullReference(local, expression);
278
									continue;
278
									continue;
279
								}
279
								}
280
								if (!this.hideNullComparisonWarnings) {
280
								if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
281
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
281
									scope.problemReporter().localVariableNullComparedToNonNull(local, expression);
282
								}
282
								}
283
								continue;
283
								continue;
Lines 470-483 Link Here
470
		case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
470
		case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL:
471
			if (flowInfo.isDefinitelyNonNull(local)) {
471
			if (flowInfo.isDefinitelyNonNull(local)) {
472
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
472
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) {
473
					if (!this.hideNullComparisonWarnings) {
473
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
474
						scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
474
						scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference);
475
					}
475
					}
476
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
476
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
477
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
477
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
478
					}
478
					}
479
				} else {
479
				} else {
480
					if (!this.hideNullComparisonWarnings) {
480
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
481
						scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
481
						scope.problemReporter().localVariableNonNullComparedToNull(local, reference);
482
					}
482
					}
483
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
483
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 486-499 Link Here
486
				}
486
				}
487
			} else if (flowInfo.isDefinitelyNull(local)) {
487
			} else if (flowInfo.isDefinitelyNull(local)) {
488
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
488
				if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) {
489
					if (!this.hideNullComparisonWarnings) {
489
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
490
						scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
490
						scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
491
					}
491
					}
492
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
492
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
493
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
493
						flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE);
494
					}
494
					}
495
				} else {
495
				} else {
496
					if (!this.hideNullComparisonWarnings) {
496
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
497
						scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
497
						scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
498
					}
498
					}
499
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
499
					if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 502-515 Link Here
502
				}
502
				}
503
			} else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local)) {    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418
503
			} else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local)) {    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418
504
				flowInfo.markAsDefinitelyNonNull(local);
504
				flowInfo.markAsDefinitelyNonNull(local);
505
				if (!this.hideNullComparisonWarnings) {
505
				if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
506
					recordNullReference(local, reference, checkType);
506
					recordNullReference(local, reference, checkType);
507
				}
507
				}
508
			} else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) {
508
			} else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) {
509
				if (flowInfo.isPotentiallyNonNull(local)) {
509
				if (flowInfo.isPotentiallyNonNull(local)) {
510
					recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK);
510
					recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK);
511
				} else {
511
				} else {
512
					if (!this.hideNullComparisonWarnings) {
512
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
513
						recordNullReference(local, reference, checkType);
513
						recordNullReference(local, reference, checkType);
514
					}
514
					}
515
				}
515
				}
Lines 530-536 Link Here
530
							scope.problemReporter().localVariableNullReference(local, reference);
530
							scope.problemReporter().localVariableNullReference(local, reference);
531
							return;
531
							return;
532
						}
532
						}
533
						if (!this.hideNullComparisonWarnings) {
533
						if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
534
							scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
534
							scope.problemReporter().localVariableRedundantCheckOnNull(local, reference);
535
						}
535
						}
536
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
536
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 542-548 Link Here
542
							scope.problemReporter().localVariableNullReference(local, reference);
542
							scope.problemReporter().localVariableNullReference(local, reference);
543
							return;
543
							return;
544
						}
544
						}
545
						if (!this.hideNullComparisonWarnings) {
545
						if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
546
							scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
546
							scope.problemReporter().localVariableNullComparedToNonNull(local, reference);
547
						}
547
						}
548
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
548
						if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) {
Lines 574-580 Link Here
574
			}
574
			}
575
			// if the contention is inside assert statement, we want to avoid null warnings only in case of
575
			// if the contention is inside assert statement, we want to avoid null warnings only in case of
576
			// comparisons and not in case of assignment and instanceof
576
			// comparisons and not in case of assignment and instanceof
577
			if (!this.hideNullComparisonWarnings 
577
			if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0 
578
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_ASSIGNMENT
578
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_ASSIGNMENT
579
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_INSTANCEOF) {
579
					|| (checkType & CONTEXT_MASK) == FlowContext.IN_INSTANCEOF) {
580
				recordNullReference(local, reference, checkType);
580
				recordNullReference(local, reference, checkType);

Return to bug 303810