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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+3 lines)
Lines 117-122 Link Here
117
 *									MissingSynchronizedModifierInInheritedMethod
117
 *									MissingSynchronizedModifierInInheritedMethod
118
 *		Stephan Herrmann  - added the following constants
118
 *		Stephan Herrmann  - added the following constants
119
 *									UnusedObjectAllocation									
119
 *									UnusedObjectAllocation									
120
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
120
 *******************************************************************************/
121
 *******************************************************************************/
121
package org.eclipse.jdt.core.compiler;
122
package org.eclipse.jdt.core.compiler;
122
123
Lines 359-364 Link Here
359
	int DuplicateBlankFinalFieldInitialization = FieldRelated + 82;
360
	int DuplicateBlankFinalFieldInitialization = FieldRelated + 82;
360
	/** @since 3.6 */
361
	/** @since 3.6 */
361
	int UnresolvedVariable = FieldRelated + 83;
362
	int UnresolvedVariable = FieldRelated + 83;
363
	/** @since 3.7 */
364
	int UnusedScopedField = Internal + FieldRelated + 84;
362
365
363
	// variable hiding
366
	// variable hiding
364
	/** @since 3.0 */
367
	/** @since 3.0 */
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-5 / +12 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matt McCutchen - partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
10
 *     Matt McCutchen - partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
11
 *     Karen Moore - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=207411
11
 *     Karen Moore - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=207411
12
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.compiler.ast;
14
package org.eclipse.jdt.internal.compiler.ast;
14
15
Lines 357-367 Link Here
357
		return this;
358
		return this;
358
	}
359
	}
359
360
360
	public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, boolean isStrictlyAssigned) {
361
	public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, int filteredBits) {
361
		// ignore references insing Javadoc comments
362
		if ((this.bits & ASTNode.InsideJavadoc) == 0			// ignore references inside Javadoc comments 
362
		if ((this.bits & ASTNode.InsideJavadoc) == 0 && !isStrictlyAssigned && field.isOrEnclosedByPrivateType() && !scope.isDefinedInField(field)) {
363
				&& (filteredBits & IsStrictlyAssigned) == 0 	// ignore write access
363
			// ignore cases where field is used from inside itself
364
				&& field.isOrEnclosedByPrivateType() 
364
			field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
365
				&& !scope.isDefinedInField(field)) 				// ignore cases where field is used from inside itself 
366
		{		
367
			if (((filteredBits & IsCompoundAssigned) != 0))
368
				// used, but usage may not be relevant
369
				field.original().modifiers |= ExtraCompilerModifiers.AccCompoundUsed;
370
			else
371
				field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
365
		}
372
		}
366
373
367
		if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
374
		if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-1 / +10 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 290-295 Link Here
290
291
291
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
292
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
292
	boolean isStatic;
293
	boolean isStatic;
294
	if (!valueRequired) {
295
		// check if compound assignment is the only usage of a private field
296
		SingleNameReference.reportOnlyUselesslyReadPrivateField(currentScope, this, this.binding);
297
	}
293
	FieldBinding codegenBinding = this.binding.original();
298
	FieldBinding codegenBinding = this.binding.original();
294
	this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
299
	this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
295
	if (isStatic) {
300
	if (isStatic) {
Lines 337-342 Link Here
337
342
338
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
343
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
339
	boolean isStatic;
344
	boolean isStatic;
345
	if (!valueRequired) {
346
		// check if postIncrement is the only usage of a private field
347
		SingleNameReference.reportOnlyUselesslyReadPrivateField(currentScope, this, this.binding);
348
	}
340
	FieldBinding codegenBinding = this.binding.original();
349
	FieldBinding codegenBinding = this.binding.original();
341
	this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
350
	this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
342
	if (isStatic) {
351
	if (isStatic) {
Lines 577-583 Link Here
577
	if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
586
	if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
578
		this.bits |= NeedReceiverGenericCast;
587
		this.bits |= NeedReceiverGenericCast;
579
	}
588
	}
580
	if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0)) {
589
	if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) {
581
		scope.problemReporter().deprecatedField(fieldBinding, this);
590
		scope.problemReporter().deprecatedField(fieldBinding, this);
582
	}
591
	}
583
	boolean isImplicitThisRcv = this.receiver.isImplicitThis();
592
	boolean isImplicitThisRcv = this.receiver.isImplicitThis();
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 97-103 Link Here
97
		}
98
		}
98
		this.binding = (FieldBinding) fieldBinding;
99
		this.binding = (FieldBinding) fieldBinding;
99
100
100
		if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) {
101
		if (isFieldUseDeprecated(this.binding, scope, this.bits)) {
101
			scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers());
102
			scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers());
102
		}
103
		}
103
		return this.resolvedType = this.binding.type;
104
		return this.resolvedType = this.binding.type;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-2 / +11 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 380-385 Link Here
380
381
381
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
382
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
382
	FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
383
	FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
384
	if (!valueRequired) {
385
		// check if compound assignment is the only usage of a private field
386
		SingleNameReference.reportOnlyUselesslyReadPrivateField(currentScope, this, lastFieldBinding);
387
	}
383
	boolean isFirst = lastFieldBinding == this.binding
388
	boolean isFirst = lastFieldBinding == this.binding
384
		&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
389
		&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
385
		&& this.otherBindings == null; // could be dup: next.next.next
390
		&& this.otherBindings == null; // could be dup: next.next.next
Lines 431-436 Link Here
431
436
432
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
437
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
433
	FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
438
	FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
439
	if (!valueRequired) {
440
		// check if this post increment is the only usage of a private field
441
		SingleNameReference.reportOnlyUselesslyReadPrivateField(currentScope, this, lastFieldBinding);
442
	}
434
	boolean isFirst = lastFieldBinding == this.binding
443
	boolean isFirst = lastFieldBinding == this.binding
435
		&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
444
		&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType())
436
		&& this.otherBindings == null; // could be dup: next.next.next
445
		&& this.otherBindings == null; // could be dup: next.next.next
Lines 719-725 Link Here
719
				}				
728
				}				
720
		    }
729
		    }
721
			// only last field is actually a write access if any
730
			// only last field is actually a write access if any
722
			if (isFieldUseDeprecated(field, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0 && index+1 == length)) {
731
			if (isFieldUseDeprecated(field, scope, index+1 == length ? this.bits : 0)) {
723
				scope.problemReporter().deprecatedField(field, this);
732
				scope.problemReporter().deprecatedField(field, this);
724
			}
733
			}
725
			// constant propagation can only be performed as long as the previous one is a constant too.
734
			// constant propagation can only be performed as long as the previous one is a constant too.
Lines 954-960 Link Here
954
							&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
963
							&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
955
						scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
964
						scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
956
					}
965
					}
957
					if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) != 0 && this.indexOfFirstFieldBinding == this.tokens.length)) {
966
					if (isFieldUseDeprecated(fieldBinding, scope, this.indexOfFirstFieldBinding == this.tokens.length ? this.bits : 0)) {
958
						scope.problemReporter().deprecatedField(fieldBinding, this);	
967
						scope.problemReporter().deprecatedField(fieldBinding, this);	
959
					}
968
					}
960
					if (fieldBinding.isStatic()) {
969
					if (fieldBinding.isStatic()) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-7 / +82 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment,
11
 *     											    Contribution for bug 185682 - Increment/decrement operators mark local variables as read
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.jdt.internal.compiler.ast;
13
package org.eclipse.jdt.internal.compiler.ast;
13
14
Lines 23-28 Link Here
23
import org.eclipse.jdt.internal.compiler.lookup.Binding;
24
import org.eclipse.jdt.internal.compiler.lookup.Binding;
24
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
25
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
25
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
26
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
27
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
26
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
Lines 78-87 Link Here
78
					currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
80
					currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
79
					// we could improve error msg here telling "cannot use compound assignment on final local variable"
81
					// we could improve error msg here telling "cannot use compound assignment on final local variable"
80
				}
82
				}
81
				if (isReachable) {
83
				if (localBinding.useFlag != LocalVariableBinding.USED) {
82
					localBinding.useFlag = LocalVariableBinding.USED;
84
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
83
				} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
85
					// access from compound assignment does not prevent "unused" warning, unless unboxing is involved:
84
					localBinding.useFlag = LocalVariableBinding.FAKE_USED;
86
					if (isReachable && (this.implicitConversion & TypeIds.UNBOXING) != 0) {
87
						localBinding.useFlag = LocalVariableBinding.USED;
88
					} else {
89
						localBinding.useFlag = LocalVariableBinding.FAKE_USED;
90
					}
85
				}
91
				}
86
		}
92
		}
87
	}
93
	}
Lines 204-210 Link Here
204
		}
210
		}
205
	}
211
	}
206
212
207
	if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0))
213
	if (isFieldUseDeprecated(fieldBinding, scope, this.bits))
208
		scope.problemReporter().deprecatedField(fieldBinding, this);
214
		scope.problemReporter().deprecatedField(fieldBinding, this);
209
215
210
	if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
216
	if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
Lines 462-467 Link Here
462
 * are optimized in one access: e.g "a = a + 1" optimized into "a++".
468
 * are optimized in one access: e.g "a = a + 1" optimized into "a++".
463
 */
469
 */
464
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
470
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
471
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
472
	if (!valueRequired) {
473
		switch (this.bits & ASTNode.RestrictiveFlagMASK) {
474
			case Binding.LOCAL:
475
				LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
476
				if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) {
477
					// compound assignment is the only usage of this local
478
					reportOnlyUselesslyReadLocal(currentScope, localBinding);
479
				}
480
				break;
481
			case Binding.FIELD:
482
				// check if compound assignment is the only usage of a private field
483
				reportOnlyUselesslyReadPrivateField(currentScope, this, (FieldBinding)this.binding);
484
		}
485
	}
465
	this.generateCompoundAssignment(
486
	this.generateCompoundAssignment(
466
		currentScope,
487
		currentScope,
467
		codeStream,
488
		codeStream,
Lines 599-605 Link Here
599
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
620
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
600
	switch (this.bits & ASTNode.RestrictiveFlagMASK) {
621
	switch (this.bits & ASTNode.RestrictiveFlagMASK) {
601
		case Binding.FIELD : // assigning to a field
622
		case Binding.FIELD : // assigning to a field
602
			FieldBinding codegenField = (((FieldBinding)this.binding).original());
623
			FieldBinding fieldBinding = (FieldBinding)this.binding;
624
			if (!valueRequired) {
625
				// check if postIncrement is the only usage of a private field
626
				reportOnlyUselesslyReadPrivateField(currentScope, this, fieldBinding);
627
			}
628
			FieldBinding codegenField = fieldBinding.original();
603
			if (codegenField.isStatic()) {
629
			if (codegenField.isStatic()) {
604
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
630
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
605
					TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
631
					TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
Lines 662-667 Link Here
662
			return;
688
			return;
663
		case Binding.LOCAL : // assigning to a local variable
689
		case Binding.LOCAL : // assigning to a local variable
664
			LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
690
			LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
691
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
692
			if (!valueRequired && localBinding.useFlag == LocalVariableBinding.FAKE_USED) {
693
				// postIncrement is the only usage of this local
694
				reportOnlyUselesslyReadLocal(currentScope, localBinding);
695
			}
696
665
			// using incr bytecode if possible
697
			// using incr bytecode if possible
666
			if (localBinding.type == TypeBinding.INT) {
698
			if (localBinding.type == TypeBinding.INT) {
667
				if (valueRequired) {
699
				if (valueRequired) {
Lines 837-842 Link Here
837
	return null;
869
	return null;
838
}
870
}
839
871
872
/* report a local/arg that is only read from a 'special operator',
873
 * i.e., in a postIncrement expression or a compound assignment,
874
 * where the information is never flowing out off the local/arg. */
875
private void reportOnlyUselesslyReadLocal(BlockScope currentScope, LocalVariableBinding localBinding) {
876
	if (localBinding.declaration == null)
877
		return;  // secret local
878
	if ((localBinding.declaration.bits & ASTNode.IsLocalDeclarationReachable) == 0)
879
		return;  // declaration is unreachable
880
	if (localBinding.declaration instanceof Argument) {
881
		// check compiler options to report against unused arguments
882
		if (currentScope instanceof MethodScope) {
883
			MethodBinding method = ((MethodDeclaration)currentScope.referenceContext()).binding;
884
			
885
			boolean shouldReport = !method.isMain();
886
			if (method.isImplementing()) {
887
				shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenImplementingAbstract;
888
			} else if (method.isOverriding()) {
889
				shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenOverridingConcrete;
890
			}
891
			
892
			if (shouldReport) {
893
				// report the case of an argument that is unread except through a special operator
894
				currentScope.problemReporter().unusedArgument(localBinding.declaration);
895
			}
896
		}
897
	} else {
898
		// report the case of a local variable that is unread except for a special operator
899
		currentScope.problemReporter().unusedLocalVariable(localBinding.declaration);
900
	}
901
	localBinding.useFlag = LocalVariableBinding.USED; // don't report again
902
}
903
904
/* report if a private field is only read from a 'special operator',
905
 * i.e., in a postIncrement expression or a compound assignment,
906
 * where the information is never flowing out off the field. */
907
static void reportOnlyUselesslyReadPrivateField(BlockScope currentScope, Reference reference, FieldBinding fieldBinding) {
908
	if (fieldBinding.isUsedOnlyInCompound() && fieldBinding.isOrEnclosedByPrivateType() && (reference.implicitConversion & TypeIds.UNBOXING) == 0) {
909
		// compoundAssignment/postIncrement is the only usage of this field
910
		currentScope.problemReporter().unusedPrivateField(fieldBinding.sourceField());
911
		fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // don't report again
912
	}
913
}
914
840
public TypeBinding resolveType(BlockScope scope) {
915
public TypeBinding resolveType(BlockScope scope) {
841
	// for code gen, harm the restrictiveFlag
916
	// for code gen, harm the restrictiveFlag
842
917
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java (-1 / +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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
12
package org.eclipse.jdt.internal.compiler.lookup;
12
13
Lines 32-37 Link Here
32
	final int AccBlankFinal = ASTNode.Bit27; // for blank final variables
33
	final int AccBlankFinal = ASTNode.Bit27; // for blank final variables
33
	final int AccIsDefaultConstructor = ASTNode.Bit27; // for default constructor
34
	final int AccIsDefaultConstructor = ASTNode.Bit27; // for default constructor
34
	final int AccLocallyUsed = ASTNode.Bit28; // used to diagnose unused private/local members
35
	final int AccLocallyUsed = ASTNode.Bit28; // used to diagnose unused private/local members
36
	final int AccCompoundUsed = ASTNode.Bit25; // used to diagnose private members used only in a compound expression/assignment
35
	final int AccVisibilityMASK = ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate;
37
	final int AccVisibilityMASK = ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate;
36
38
37
	final int AccOverriding = ASTNode.Bit29; // record fact a method overrides another one
39
	final int AccOverriding = ASTNode.Bit29; // record fact a method overrides another one
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java (-2 / +9 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
12
package org.eclipse.jdt.internal.compiler.lookup;
12
13
Lines 332-338 Link Here
332
*/
333
*/
333
334
334
public final boolean isUsed() {
335
public final boolean isUsed() {
335
	return (this.modifiers & ExtraCompilerModifiers.AccLocallyUsed) != 0;
336
	return (this.modifiers & (ExtraCompilerModifiers.AccLocallyUsed | ExtraCompilerModifiers.AccCompoundUsed)) != 0;
337
}
338
/* Answer true if the only use of this field is in compound assignment or post increment
339
 */
340
341
public final boolean isUsedOnlyInCompound() {
342
	return (this.modifiers & (ExtraCompilerModifiers.AccLocallyUsed | ExtraCompilerModifiers.AccCompoundUsed)) == ExtraCompilerModifiers.AccCompoundUsed;
336
}
343
}
337
/* Answer true if the receiver has protected visibility
344
/* Answer true if the receiver has protected visibility
338
*/
345
*/
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-2 / +7 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *     Benjamin Muskalla - Contribution for bug 239066
11
 *     Stephan Herrmann  - Contribution for bug 236385
11
 *     Stephan Herrmann  - Contribution for bug 236385
12
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.compiler.problem;
14
package org.eclipse.jdt.internal.compiler.problem;
14
15
Lines 194-199 Link Here
194
		case IProblem.UnusedPrivateConstructor:
195
		case IProblem.UnusedPrivateConstructor:
195
		case IProblem.UnusedPrivateMethod:
196
		case IProblem.UnusedPrivateMethod:
196
		case IProblem.UnusedPrivateField:
197
		case IProblem.UnusedPrivateField:
198
		case IProblem.UnusedScopedField:
197
		case IProblem.UnusedPrivateType:
199
		case IProblem.UnusedPrivateType:
198
			return CompilerOptions.UnusedPrivateMember;
200
			return CompilerOptions.UnusedPrivateMember;
199
201
Lines 7250-7256 Link Here
7250
}
7252
}
7251
public void unusedPrivateField(FieldDeclaration fieldDecl) {
7253
public void unusedPrivateField(FieldDeclaration fieldDecl) {
7252
7254
7253
	int severity = computeSeverity(IProblem.UnusedPrivateField);
7255
	int problemId = (fieldDecl.modifiers & ClassFileConstants.AccPrivate) != 0 
7256
						? IProblem.UnusedPrivateField
7257
						: IProblem.UnusedScopedField;
7258
	int severity = computeSeverity(problemId);
7254
	if (severity == ProblemSeverities.Ignore) return;
7259
	if (severity == ProblemSeverities.Ignore) return;
7255
7260
7256
	FieldBinding field = fieldDecl.binding;
7261
	FieldBinding field = fieldDecl.binding;
Lines 7269-7275 Link Here
7269
				return; // do not report unused serialPersistentFields field
7274
				return; // do not report unused serialPersistentFields field
7270
	}
7275
	}
7271
	this.handle(
7276
	this.handle(
7272
			IProblem.UnusedPrivateField,
7277
			problemId,
7273
		new String[] {
7278
		new String[] {
7274
			new String(field.declaringClass.readableName()),
7279
			new String(field.declaringClass.readableName()),
7275
			new String(field.name),
7280
			new String(field.name),
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-3 / +5 lines)
Lines 8-13 Link Here
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#		Benjamin Muskalla - Contribution for bug 239066
10
#		Benjamin Muskalla - Contribution for bug 239066
11
#		Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
11
###############################################################################
12
###############################################################################
12
0 = {0}
13
0 = {0}
13
1 = super cannot be used in java.lang.Object
14
1 = super cannot be used in java.lang.Object
Lines 49-56 Link Here
49
58 = The final local variable {0} cannot be assigned. It must be blank and not using a compound assignment
50
58 = The final local variable {0} cannot be assigned. It must be blank and not using a compound assignment
50
59 = The parameter {0} should not be assigned
51
59 = The parameter {0} should not be assigned
51
60 = The final local variable {0} cannot be assigned, since it is defined in an enclosing type
52
60 = The final local variable {0} cannot be assigned, since it is defined in an enclosing type
52
61 = The local variable {0} is never read
53
61 = The local variable {0} is never used
53
62 = The parameter {0} is never read
54
62 = The parameter {0} is never used
54
63 = The code of method {0}({1}) is exceeding the 65535 bytes limit
55
63 = The code of method {0}({1}) is exceeding the 65535 bytes limit
55
64 = The code for the static initializer is exceeding the 65535 bytes limit
56
64 = The code for the static initializer is exceeding the 65535 bytes limit
56
65 = Too many parameters, parameter {0} is exceeding the limit of 255 words eligible for method parameters
57
65 = Too many parameters, parameter {0} is exceeding the limit of 255 words eligible for method parameters
Lines 65-77 Link Here
65
74 = Cannot make a static reference to the non-static field {0}
66
74 = Cannot make a static reference to the non-static field {0}
66
75 = Cannot reference a field before it is defined
67
75 = Cannot reference a field before it is defined
67
76 = The static field {0}.{1} should be accessed in a static way
68
76 = The static field {0}.{1} should be accessed in a static way
68
77 = The field {0}.{1} is never read locally
69
77 = The private field {0}.{1} is never used
69
78 = The static field {0}.{1} should be accessed directly
70
78 = The static field {0}.{1} should be accessed directly
70
79 = Unqualified access to the field {0}.{1} 
71
79 = Unqualified access to the field {0}.{1} 
71
80 = The final field {0}.{1} cannot be assigned
72
80 = The final field {0}.{1} cannot be assigned
72
81 = The blank final field {0} may not have been initialized
73
81 = The blank final field {0} may not have been initialized
73
82 = The final field {0} may already have been assigned
74
82 = The final field {0} may already have been assigned
74
83 = {0} cannot be resolved to a variable
75
83 = {0} cannot be resolved to a variable
76
84 = The field {0}.{1} is never used locally
75
77
76
90 = The local variable {0} is hiding another local variable defined in an enclosing type scope
78
90 = The local variable {0} is hiding another local variable defined in an enclosing type scope
77
91 = The local variable {0} is hiding a field from type {1}
79
91 = The local variable {0} is hiding a field from type {1}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java (-2 / +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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.eval;
12
package org.eclipse.jdt.internal.eval;
12
13
Lines 325-331 Link Here
325
		return null;
326
		return null;
326
	}
327
	}
327
328
328
	if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) !=0)) {
329
	if (isFieldUseDeprecated(this.binding, scope, this.bits)) {
329
		scope.problemReporter().deprecatedField(this.binding, this);
330
		scope.problemReporter().deprecatedField(this.binding, this);
330
	}
331
	}
331
	// check for this.x in static is done in the resolution of the receiver
332
	// check for this.x in static is done in the resolution of the receiver
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.eval;
12
package org.eclipse.jdt.internal.eval;
12
13
Lines 463-469 Link Here
463
			}
464
			}
464
		}
465
		}
465
		// only last field is actually a write access if any
466
		// only last field is actually a write access if any
466
		if (isFieldUseDeprecated((FieldBinding) this.binding, scope, (this.bits & IsStrictlyAssigned) !=0 && this.indexOfFirstFieldBinding == length)) {
467
		if (isFieldUseDeprecated((FieldBinding) this.binding, scope, this.indexOfFirstFieldBinding == length ? this.bits : 0)) {
467
			scope.problemReporter().deprecatedField((FieldBinding) this.binding, this);
468
			scope.problemReporter().deprecatedField((FieldBinding) this.binding, this);
468
		}
469
		}
469
	}
470
	}
Lines 510-516 Link Here
510
		}
511
		}
511
		if (field.isValidBinding()) {
512
		if (field.isValidBinding()) {
512
			// only last field is actually a write access if any
513
			// only last field is actually a write access if any
513
			if (isFieldUseDeprecated(field, scope, (this.bits & IsStrictlyAssigned) !=0 && index+1 == length)) {
514
			if (isFieldUseDeprecated(field, scope, index+1 == length ? this.bits : 0)) {
514
				scope.problemReporter().deprecatedField(field, this);
515
				scope.problemReporter().deprecatedField(field, this);
515
			}
516
			}
516
			// constant propagation can only be performed as long as the previous one is a constant too.
517
			// constant propagation can only be performed as long as the previous one is a constant too.
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java (-2 / +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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.eval;
12
package org.eclipse.jdt.internal.eval;
12
13
Lines 101-107 Link Here
101
	}
102
	}
102
	this.constant = fieldBinding.constant();
103
	this.constant = fieldBinding.constant();
103
104
104
	if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & IsStrictlyAssigned) !=0)) {
105
	if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) {
105
		scope.problemReporter().deprecatedField(fieldBinding, this);
106
		scope.problemReporter().deprecatedField(fieldBinding, this);
106
	}
107
	}
107
	return fieldBinding.type;
108
	return fieldBinding.type;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-1 / +2 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann  - Contribution for bug 295551
10
 *     Stephan Herrmann  - Contribution for bug 295551
11
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.jdt.core.tests.compiler.regression;
13
package org.eclipse.jdt.core.tests.compiler.regression;
13
14
Lines 9355-9361 Link Here
9355
			"1. ERROR in A.java (at line 3)\n" + 
9356
			"1. ERROR in A.java (at line 3)\n" + 
9356
			"	private int i;\n" + 
9357
			"	private int i;\n" + 
9357
			"	            ^\n" + 
9358
			"	            ^\n" + 
9358
			"The field A.i is never read locally\n" + 
9359
			"The private field A.i is never used\n" + 
9359
			"----------\n";
9360
			"----------\n";
9360
	runNegativeTest(
9361
	runNegativeTest(
9361
			true,
9362
			true,
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java (-4 / +5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 223-234 Link Here
223
		"1. WARNING in X.java (at line 4)\n" +
224
		"1. WARNING in X.java (at line 4)\n" +
224
		"	private final Object o;\n" +
225
		"	private final Object o;\n" +
225
		"	                     ^\n" +
226
		"	                     ^\n" +
226
		"The field X.Test1.o is never read locally\n" +
227
		"The private field X.Test1.o is never used\n" +
227
		"----------\n" +
228
		"----------\n" +
228
		"2. WARNING in X.java (at line 13)\n" +
229
		"2. WARNING in X.java (at line 13)\n" +
229
		"	private final Object o;\n" +
230
		"	private final Object o;\n" +
230
		"	                     ^\n" +
231
		"	                     ^\n" +
231
		"The field X.Test2.o is never read locally\n" +
232
		"The private field X.Test2.o is never used\n" +
232
		"----------\n" +
233
		"----------\n" +
233
		"3. ERROR in X.java (at line 25)\n" +
234
		"3. ERROR in X.java (at line 25)\n" +
234
		"	System.out.println(o); // illegal; o is not definitely assigned\n" +
235
		"	System.out.println(o); // illegal; o is not definitely assigned\n" +
Lines 238-244 Link Here
238
		"4. WARNING in X.java (at line 42)\n" +
239
		"4. WARNING in X.java (at line 42)\n" +
239
		"	private final Object o;\n" +
240
		"	private final Object o;\n" +
240
		"	                     ^\n" +
241
		"	                     ^\n" +
241
		"The field X.Test5.o is never read locally\n" +
242
		"The private field X.Test5.o is never used\n" +
242
		"----------\n" +
243
		"----------\n" +
243
		"5. ERROR in X.java (at line 44)\n" +
244
		"5. ERROR in X.java (at line 44)\n" +
244
		"	Test5() {\n" +
245
		"	Test5() {\n" +
Lines 253-259 Link Here
253
		"7. WARNING in X.java (at line 52)\n" +
254
		"7. WARNING in X.java (at line 52)\n" +
254
		"	private final Object o;\n" +
255
		"	private final Object o;\n" +
255
		"	                     ^\n" +
256
		"	                     ^\n" +
256
		"The field X.Test6.o is never read locally\n" +
257
		"The private field X.Test6.o is never used\n" +
257
		"----------\n" +
258
		"----------\n" +
258
		"8. ERROR in X.java (at line 59)\n" +
259
		"8. ERROR in X.java (at line 59)\n" +
259
		"	other.o = new Object(); // illegal!  other.o is not assignable\n" +
260
		"	other.o = new Object(); // illegal!  other.o is not assignable\n" +
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-35 / +36 lines)
Lines 10-15 Link Here
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *     Benjamin Muskalla - Contribution for bug 239066
11
 *     Stephan Herrmann  - Contribution for bug 236385
11
 *     Stephan Herrmann  - Contribution for bug 236385
12
 *     Stephan Herrmann  - Contribution for bug 295551
12
 *     Stephan Herrmann  - Contribution for bug 295551
13
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.core.tests.compiler.regression;
15
package org.eclipse.jdt.core.tests.compiler.regression;
15
16
Lines 2879-2885 Link Here
2879
	        "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
2880
	        "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
2880
	        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
2881
	        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
2881
	        "	                ^^\n" +
2882
	        "	                ^^\n" +
2882
	        "The local variable l1 is never read\n" +
2883
	        "The local variable l1 is never used\n" +
2883
	        "----------\n" +
2884
	        "----------\n" +
2884
	        "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
2885
	        "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
2885
	        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
2886
	        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
Lines 3059-3065 Link Here
3059
        "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
3060
        "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
3060
        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
3061
        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
3061
        "	                ^^\n" +
3062
        "	                ^^\n" +
3062
        "The local variable l1 is never read\n" +
3063
        "The local variable l1 is never used\n" +
3063
        "----------\n" +
3064
        "----------\n" +
3064
        "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
3065
        "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" +
3065
        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
3066
        "	final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" +
Lines 6228-6234 Link Here
6228
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6229
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6229
		"	String u;\n" +
6230
		"	String u;\n" +
6230
		"	       ^\n" +
6231
		"	       ^\n" +
6231
		"The local variable u is never read\n" +
6232
		"The local variable u is never used\n" +
6232
		"----------\n" +
6233
		"----------\n" +
6233
		"2 problems (2 warnings)",
6234
		"2 problems (2 warnings)",
6234
		true);
6235
		true);
Lines 6315-6321 Link Here
6315
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6316
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6316
		"	String u;\n" +
6317
		"	String u;\n" +
6317
		"	       ^\n" +
6318
		"	       ^\n" +
6318
		"The local variable u is never read\n" +
6319
		"The local variable u is never used\n" +
6319
		"----------\n" +
6320
		"----------\n" +
6320
		"1 problem (1 warning)",
6321
		"1 problem (1 warning)",
6321
		true);
6322
		true);
Lines 6347-6353 Link Here
6347
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6348
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6348
		"	String u;\n" +
6349
		"	String u;\n" +
6349
		"	       ^\n" +
6350
		"	       ^\n" +
6350
		"The local variable u is never read\n" +
6351
		"The local variable u is never used\n" +
6351
		"----------\n" +
6352
		"----------\n" +
6352
		"2 problems (2 warnings)",
6353
		"2 problems (2 warnings)",
6353
		true);
6354
		true);
Lines 6374-6380 Link Here
6374
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6375
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6375
		"	String u;\n" +
6376
		"	String u;\n" +
6376
		"	       ^\n" +
6377
		"	       ^\n" +
6377
		"The local variable u is never read\n" +
6378
		"The local variable u is never used\n" +
6378
		"----------\n" +
6379
		"----------\n" +
6379
		"1 problem (1 warning)",
6380
		"1 problem (1 warning)",
6380
		true);
6381
		true);
Lines 6400-6406 Link Here
6400
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6401
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6401
		"	String u;\n" +
6402
		"	String u;\n" +
6402
		"	       ^\n" +
6403
		"	       ^\n" +
6403
		"The local variable u is never read\n" +
6404
		"The local variable u is never used\n" +
6404
		"----------\n" +
6405
		"----------\n" +
6405
		"1 problem (1 warning)",
6406
		"1 problem (1 warning)",
6406
		true);
6407
		true);
Lines 6431-6437 Link Here
6431
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6432
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6432
		"	String u;\n" +
6433
		"	String u;\n" +
6433
		"	       ^\n" +
6434
		"	       ^\n" +
6434
		"The local variable u is never read\n" +
6435
		"The local variable u is never used\n" +
6435
		"----------\n" +
6436
		"----------\n" +
6436
		"2 problems (2 warnings)",
6437
		"2 problems (2 warnings)",
6437
		true);
6438
		true);
Lines 6463-6469 Link Here
6463
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6464
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
6464
		"	String u;\n" +
6465
		"	String u;\n" +
6465
		"	       ^\n" +
6466
		"	       ^\n" +
6466
		"The local variable u is never read\n" +
6467
		"The local variable u is never used\n" +
6467
		"----------\n" +
6468
		"----------\n" +
6468
		"2 problems (2 warnings)",
6469
		"2 problems (2 warnings)",
6469
		true);
6470
		true);
Lines 7564-7570 Link Here
7564
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7565
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7565
		"	int j;\n" +
7566
		"	int j;\n" +
7566
		"	    ^\n" +
7567
		"	    ^\n" +
7567
		"The local variable j is never read\n" +
7568
		"The local variable j is never used\n" +
7568
		"----------\n" +
7569
		"----------\n" +
7569
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7570
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7570
		"	this.<String>bar();\n" +
7571
		"	this.<String>bar();\n" +
Lines 7627-7633 Link Here
7627
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7628
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7628
		"	private void foo(int i) throws java.io.IOException {\n" +
7629
		"	private void foo(int i) throws java.io.IOException {\n" +
7629
		"	                     ^\n" +
7630
		"	                     ^\n" +
7630
		"The parameter i is never read\n" +
7631
		"The parameter i is never used\n" +
7631
		"----------\n" +
7632
		"----------\n" +
7632
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7633
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7633
		"	private void foo(int i) throws java.io.IOException {\n" +
7634
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 7637-7643 Link Here
7637
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7638
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7638
		"	int j;\n" +
7639
		"	int j;\n" +
7639
		"	    ^\n" +
7640
		"	    ^\n" +
7640
		"The local variable j is never read\n" +
7641
		"The local variable j is never used\n" +
7641
		"----------\n" +
7642
		"----------\n" +
7642
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7643
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7643
		"	this.<String>bar();\n" +
7644
		"	this.<String>bar();\n" +
Lines 7682-7688 Link Here
7682
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7683
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7683
		"	private void foo(int i) throws java.io.IOException {\n" +
7684
		"	private void foo(int i) throws java.io.IOException {\n" +
7684
		"	                     ^\n" +
7685
		"	                     ^\n" +
7685
		"The parameter i is never read\n" +
7686
		"The parameter i is never used\n" +
7686
		"----------\n" +
7687
		"----------\n" +
7687
		"1 problem (1 warning)",
7688
		"1 problem (1 warning)",
7688
		true);
7689
		true);
Lines 7787-7793 Link Here
7787
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7788
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7788
		"	int j;\n" +
7789
		"	int j;\n" +
7789
		"	    ^\n" +
7790
		"	    ^\n" +
7790
		"The local variable j is never read\n" +
7791
		"The local variable j is never used\n" +
7791
		"----------\n" +
7792
		"----------\n" +
7792
		"1 problem (1 warning)",
7793
		"1 problem (1 warning)",
7793
		true);
7794
		true);
Lines 7942-7948 Link Here
7942
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7943
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
7943
		"	int j;\n" +
7944
		"	int j;\n" +
7944
		"	    ^\n" +
7945
		"	    ^\n" +
7945
		"The local variable j is never read\n" +
7946
		"The local variable j is never used\n" +
7946
		"----------\n" +
7947
		"----------\n" +
7947
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7948
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
7948
		"	this.<String>bar();\n" +
7949
		"	this.<String>bar();\n" +
Lines 7992-7998 Link Here
7992
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7993
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7993
		"	private void foo(int i) throws java.io.IOException {\n" +
7994
		"	private void foo(int i) throws java.io.IOException {\n" +
7994
		"	                     ^\n" +
7995
		"	                     ^\n" +
7995
		"The parameter i is never read\n" +
7996
		"The parameter i is never used\n" +
7996
		"----------\n" +
7997
		"----------\n" +
7997
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7998
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
7998
		"	private void foo(int i) throws java.io.IOException {\n" +
7999
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 8002-8008 Link Here
8002
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8003
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8003
		"	int j;\n" +
8004
		"	int j;\n" +
8004
		"	    ^\n" +
8005
		"	    ^\n" +
8005
		"The local variable j is never read\n" +
8006
		"The local variable j is never used\n" +
8006
		"----------\n" +
8007
		"----------\n" +
8007
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8008
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8008
		"	this.<String>bar();\n" +
8009
		"	this.<String>bar();\n" +
Lines 8057-8063 Link Here
8057
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8058
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8058
		"	private void foo(int i) throws java.io.IOException {\n" +
8059
		"	private void foo(int i) throws java.io.IOException {\n" +
8059
		"	                     ^\n" +
8060
		"	                     ^\n" +
8060
		"The parameter i is never read\n" +
8061
		"The parameter i is never used\n" +
8061
		"----------\n" +
8062
		"----------\n" +
8062
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8063
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8063
		"	private void foo(int i) throws java.io.IOException {\n" +
8064
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 8067-8073 Link Here
8067
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8068
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8068
		"	int j;\n" +
8069
		"	int j;\n" +
8069
		"	    ^\n" +
8070
		"	    ^\n" +
8070
		"The local variable j is never read\n" +
8071
		"The local variable j is never used\n" +
8071
		"----------\n" +
8072
		"----------\n" +
8072
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8073
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8073
		"	this.<String>bar();\n" +
8074
		"	this.<String>bar();\n" +
Lines 8117-8123 Link Here
8117
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8118
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8118
		"	private void foo(int i) throws java.io.IOException {\n" +
8119
		"	private void foo(int i) throws java.io.IOException {\n" +
8119
		"	                     ^\n" +
8120
		"	                     ^\n" +
8120
		"The parameter i is never read\n" +
8121
		"The parameter i is never used\n" +
8121
		"----------\n" +
8122
		"----------\n" +
8122
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8123
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8123
		"	private void foo(int i) throws java.io.IOException {\n" +
8124
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 8172-8178 Link Here
8172
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8173
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8173
		"	private void foo(int i) throws java.io.IOException {\n" +
8174
		"	private void foo(int i) throws java.io.IOException {\n" +
8174
		"	                     ^\n" +
8175
		"	                     ^\n" +
8175
		"The parameter i is never read\n" +
8176
		"The parameter i is never used\n" +
8176
		"----------\n" +
8177
		"----------\n" +
8177
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8178
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8178
		"	private void foo(int i) throws java.io.IOException {\n" +
8179
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 8182-8188 Link Here
8182
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8183
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8183
		"	int j;\n" +
8184
		"	int j;\n" +
8184
		"	    ^\n" +
8185
		"	    ^\n" +
8185
		"The local variable j is never read\n" +
8186
		"The local variable j is never used\n" +
8186
		"----------\n" +
8187
		"----------\n" +
8187
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8188
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8188
		"	this.<String>bar();\n" +
8189
		"	this.<String>bar();\n" +
Lines 8237-8248 Link Here
8237
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8238
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8238
		"	private void foo(int i) throws java.io.IOException {\n" +
8239
		"	private void foo(int i) throws java.io.IOException {\n" +
8239
		"	                     ^\n" +
8240
		"	                     ^\n" +
8240
		"The parameter i is never read\n" +
8241
		"The parameter i is never used\n" +
8241
		"----------\n" +
8242
		"----------\n" +
8242
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8243
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8243
		"	int j;\n" +
8244
		"	int j;\n" +
8244
		"	    ^\n" +
8245
		"	    ^\n" +
8245
		"The local variable j is never read\n" +
8246
		"The local variable j is never used\n" +
8246
		"----------\n" +
8247
		"----------\n" +
8247
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8248
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8248
		"	this.<String>bar();\n" +
8249
		"	this.<String>bar();\n" +
Lines 8297-8303 Link Here
8297
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8298
		"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8298
		"	private void foo(int i) throws java.io.IOException {\n" +
8299
		"	private void foo(int i) throws java.io.IOException {\n" +
8299
		"	                     ^\n" +
8300
		"	                     ^\n" +
8300
		"The parameter i is never read\n" +
8301
		"The parameter i is never used\n" +
8301
		"----------\n" +
8302
		"----------\n" +
8302
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8303
		"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
8303
		"	private void foo(int i) throws java.io.IOException {\n" +
8304
		"	private void foo(int i) throws java.io.IOException {\n" +
Lines 8307-8313 Link Here
8307
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8308
		"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" +
8308
		"	int j;\n" +
8309
		"	int j;\n" +
8309
		"	    ^\n" +
8310
		"	    ^\n" +
8310
		"The local variable j is never read\n" +
8311
		"The local variable j is never used\n" +
8311
		"----------\n" +
8312
		"----------\n" +
8312
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
8313
		"6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
8313
		"	next: for (;;) {\n" +
8314
		"	next: for (;;) {\n" +
Lines 8380-8386 Link Here
8380
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8381
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8381
		"	public void foo(int i) {\n" +
8382
		"	public void foo(int i) {\n" +
8382
		"	                    ^\n" +
8383
		"	                    ^\n" +
8383
		"The parameter i is never read\n" +
8384
		"The parameter i is never used\n" +
8384
		"----------\n" +
8385
		"----------\n" +
8385
		"1 problem (1 warning)",
8386
		"1 problem (1 warning)",
8386
		true);
8387
		true);
Lines 8471-8477 Link Here
8471
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8472
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8472
		"	public void foo(int i) {\n" +
8473
		"	public void foo(int i) {\n" +
8473
		"	                    ^\n" +
8474
		"	                    ^\n" +
8474
		"The parameter i is never read\n" +
8475
		"The parameter i is never used\n" +
8475
		"----------\n" +
8476
		"----------\n" +
8476
		"2 problems (2 warnings)",
8477
		"2 problems (2 warnings)",
8477
		true);
8478
		true);
Lines 8497-8503 Link Here
8497
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8498
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8498
		"	public void foo(int i) {\n" +
8499
		"	public void foo(int i) {\n" +
8499
		"	                    ^\n" +
8500
		"	                    ^\n" +
8500
		"The parameter i is never read\n" +
8501
		"The parameter i is never used\n" +
8501
		"----------\n" +
8502
		"----------\n" +
8502
		"1 problem (1 warning)",
8503
		"1 problem (1 warning)",
8503
		true);
8504
		true);
Lines 8979-8985 Link Here
8979
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8980
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
8980
		"	public void foo(int i) {\n" +
8981
		"	public void foo(int i) {\n" +
8981
		"	                    ^\n" +
8982
		"	                    ^\n" +
8982
		"The parameter i is never read\n" +
8983
		"The parameter i is never used\n" +
8983
		"----------\n" +
8984
		"----------\n" +
8984
		"1 problem (1 warning)",
8985
		"1 problem (1 warning)",
8985
		true);
8986
		true);
Lines 11334-11340 Link Here
11334
		"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11335
		"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11335
		"	private int i;\n" + 
11336
		"	private int i;\n" + 
11336
		"	            ^\n" + 
11337
		"	            ^\n" + 
11337
		"The field X.i is never read locally\n" + 
11338
		"The private field X.i is never used\n" + 
11338
		"----------\n" + 
11339
		"----------\n" + 
11339
		"2 problems (1 error, 1 warning)",
11340
		"2 problems (1 error, 1 warning)",
11340
		true);
11341
		true);
Lines 11374-11380 Link Here
11374
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11375
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11375
		"	private int i;\n" + 
11376
		"	private int i;\n" + 
11376
		"	            ^\n" + 
11377
		"	            ^\n" + 
11377
		"The field X.i is never read locally\n" + 
11378
		"The private field X.i is never used\n" + 
11378
		"----------\n" + 
11379
		"----------\n" + 
11379
		"1 problem (1 error)",
11380
		"1 problem (1 error)",
11380
		true);
11381
		true);
Lines 11397-11403 Link Here
11397
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11398
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11398
		"	private int i;\n" + 
11399
		"	private int i;\n" + 
11399
		"	            ^\n" + 
11400
		"	            ^\n" + 
11400
		"The field X.i is never read locally\n" + 
11401
		"The private field X.i is never used\n" + 
11401
		"----------\n" + 
11402
		"----------\n" + 
11402
		"1 problem (1 error)",
11403
		"1 problem (1 error)",
11403
		true);
11404
		true);
Lines 11425-11431 Link Here
11425
		"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11426
		"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11426
		"	private int i;\n" + 
11427
		"	private int i;\n" + 
11427
		"	            ^\n" + 
11428
		"	            ^\n" + 
11428
		"The field X.i is never read locally\n" + 
11429
		"The private field X.i is never used\n" + 
11429
		"----------\n" + 
11430
		"----------\n" + 
11430
		"2 problems (1 error, 1 warning)",
11431
		"2 problems (1 error, 1 warning)",
11431
		true);
11432
		true);
Lines 11448-11454 Link Here
11448
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11449
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11449
		"	private int i;\n" + 
11450
		"	private int i;\n" + 
11450
		"	            ^\n" + 
11451
		"	            ^\n" + 
11451
		"The field X.i is never read locally\n" + 
11452
		"The private field X.i is never used\n" + 
11452
		"----------\n" + 
11453
		"----------\n" + 
11453
		"1 problem (1 error)",
11454
		"1 problem (1 error)",
11454
		true);
11455
		true);
(-)src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (+3 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *     Benjamin Muskalla - Contribution for bug 239066
11
 *     Stephan Herrmann  - Contribution for bug 236385
11
 *     Stephan Herrmann  - Contribution for bug 236385
12
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.core.tests.compiler.regression;
14
package org.eclipse.jdt.core.tests.compiler.regression;
14
15
Lines 848-853 Link Here
848
		expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
849
		expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
849
		expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
850
		expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
850
		expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
851
		expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
852
		expectedProblemAttributes.put("UnusedScopedField", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
851
		expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
853
		expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
852
		expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
854
		expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
853
		expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
855
		expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
Lines 1482-1487 Link Here
1482
		expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_OBJECT_ALLOCATION));
1484
		expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_OBJECT_ALLOCATION));
1483
		expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1485
		expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1484
		expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1486
		expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1487
		expectedProblemAttributes.put("UnusedScopedField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1485
		expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1488
		expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1486
		expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1489
		expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1487
		expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_TYPE_ARGUMENTS_FOR_METHOD_INVOCATION));
1490
		expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_TYPE_ARGUMENTS_FOR_METHOD_INVOCATION));
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-2 / +3 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 7190-7201 Link Here
7190
		"1. WARNING in X.java (at line 2)\n" +
7191
		"1. WARNING in X.java (at line 2)\n" +
7191
		"	private int unused1;\n" +
7192
		"	private int unused1;\n" +
7192
		"	            ^^^^^^^\n" +
7193
		"	            ^^^^^^^\n" +
7193
		"The field X.unused1 is never read locally\n" +
7194
		"The private field X.unused1 is never used\n" +
7194
		"----------\n" +
7195
		"----------\n" +
7195
		"2. WARNING in X.java (at line 7)\n" +
7196
		"2. WARNING in X.java (at line 7)\n" +
7196
		"	private int unused2;\n" +
7197
		"	private int unused2;\n" +
7197
		"	            ^^^^^^^\n" +
7198
		"	            ^^^^^^^\n" +
7198
		"The field X.unused2 is never read locally\n" +
7199
		"The private field X.unused2 is never used\n" +
7199
		"----------\n",
7200
		"----------\n",
7200
		null, null,
7201
		null, null,
7201
		JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings
7202
		JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java (-4 / +5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 279-285 Link Here
279
		"1. WARNING in test\\AbstractVisibility.java (at line 5)\n" + 
280
		"1. WARNING in test\\AbstractVisibility.java (at line 5)\n" + 
280
		"	public int avf_public = avf_private;\n" + 
281
		"	public int avf_public = avf_private;\n" + 
281
		"	           ^^^^^^^^^^\n" + 
282
		"	           ^^^^^^^^^^\n" + 
282
		"The field AbstractVisibility.AvcPrivate.avf_public is never read locally\n" + 
283
		"The field AbstractVisibility.AvcPrivate.avf_public is never used locally\n" + 
283
		"----------\n" + 
284
		"----------\n" + 
284
		"2. WARNING in test\\AbstractVisibility.java (at line 10)\n" + 
285
		"2. WARNING in test\\AbstractVisibility.java (at line 10)\n" + 
285
		"	public int avm_public() {\n" + 
286
		"	public int avm_public() {\n" + 
Lines 290-296 Link Here
290
		"1. WARNING in test\\Visibility.java (at line 5)\n" + 
291
		"1. WARNING in test\\Visibility.java (at line 5)\n" + 
291
		"	public int vf_public = vf_private;\n" + 
292
		"	public int vf_public = vf_private;\n" + 
292
		"	           ^^^^^^^^^\n" + 
293
		"	           ^^^^^^^^^\n" + 
293
		"The field Visibility.VcPrivate.vf_public is never read locally\n" + 
294
		"The field Visibility.VcPrivate.vf_public is never used locally\n" + 
294
		"----------\n" + 
295
		"----------\n" + 
295
		"2. WARNING in test\\Visibility.java (at line 11)\n" + 
296
		"2. WARNING in test\\Visibility.java (at line 11)\n" + 
296
		"	public int vm_public() {\n" + 
297
		"	public int vm_public() {\n" + 
Lines 301-307 Link Here
301
		"1. WARNING in test\\copy\\VisibilityPackage.java (at line 5)\n" + 
302
		"1. WARNING in test\\copy\\VisibilityPackage.java (at line 5)\n" + 
302
		"	public int vf_public = vf_private;\n" + 
303
		"	public int vf_public = vf_private;\n" + 
303
		"	           ^^^^^^^^^\n" + 
304
		"	           ^^^^^^^^^\n" + 
304
		"The field VisibilityPackage.VpPrivate.vf_public is never read locally\n" + 
305
		"The field VisibilityPackage.VpPrivate.vf_public is never used locally\n" + 
305
		"----------\n" + 
306
		"----------\n" + 
306
		"2. WARNING in test\\copy\\VisibilityPackage.java (at line 10)\n" + 
307
		"2. WARNING in test\\copy\\VisibilityPackage.java (at line 10)\n" + 
307
		"	public int vm_public() {\n" + 
308
		"	public int vm_public() {\n" + 
Lines 312-318 Link Here
312
		"1. WARNING in test\\copy\\VisibilityPublic.java (at line 5)\n" + 
313
		"1. WARNING in test\\copy\\VisibilityPublic.java (at line 5)\n" + 
313
		"	public int vf_public = vf_private;\n" + 
314
		"	public int vf_public = vf_private;\n" + 
314
		"	           ^^^^^^^^^\n" + 
315
		"	           ^^^^^^^^^\n" + 
315
		"The field VisibilityPublic.VpPrivate.vf_public is never read locally\n" + 
316
		"The field VisibilityPublic.VpPrivate.vf_public is never used locally\n" + 
316
		"----------\n" + 
317
		"----------\n" + 
317
		"2. WARNING in test\\copy\\VisibilityPublic.java (at line 10)\n" + 
318
		"2. WARNING in test\\copy\\VisibilityPublic.java (at line 10)\n" + 
318
		"	public int vm_public() {\n" + 
319
		"	public int vm_public() {\n" + 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java (-20 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 411-417 Link Here
411
		"1. ERROR in X.java (at line 7)\n" +
412
		"1. ERROR in X.java (at line 7)\n" +
412
		"	void bar(int value) { // X#bar(...)\n" +
413
		"	void bar(int value) { // X#bar(...)\n" +
413
		"	             ^^^^^\n" +
414
		"	             ^^^^^\n" +
414
		"The parameter value is never read\n" +
415
		"The parameter value is never used\n" +
415
		"----------\n",
416
		"----------\n",
416
		// javac options
417
		// javac options
417
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
418
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
Lines 469-485 Link Here
469
		"1. ERROR in X.java (at line 5)\n" +
470
		"1. ERROR in X.java (at line 5)\n" +
470
		"	void foo(int value) { // X#foo(...)\n" +
471
		"	void foo(int value) { // X#foo(...)\n" +
471
		"	             ^^^^^\n" +
472
		"	             ^^^^^\n" +
472
		"The parameter value is never read\n" +
473
		"The parameter value is never used\n" +
473
		"----------\n" +
474
		"----------\n" +
474
		"2. ERROR in X.java (at line 7)\n" +
475
		"2. ERROR in X.java (at line 7)\n" +
475
		"	void bar(int value) { // X#bar(...)\n" +
476
		"	void bar(int value) { // X#bar(...)\n" +
476
		"	             ^^^^^\n" +
477
		"	             ^^^^^\n" +
477
		"The parameter value is never read\n" +
478
		"The parameter value is never used\n" +
478
		"----------\n" +
479
		"----------\n" +
479
		"3. ERROR in X.java (at line 24)\n" +
480
		"3. ERROR in X.java (at line 24)\n" +
480
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
481
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
481
		"	                ^^^^^\n" +
482
		"	                ^^^^^\n" +
482
		"The parameter value is never read\n" +
483
		"The parameter value is never used\n" +
483
		"----------\n",
484
		"----------\n",
484
		// javac options
485
		// javac options
485
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
486
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
Lines 537-553 Link Here
537
		"1. ERROR in X.java (at line 5)\n" +
538
		"1. ERROR in X.java (at line 5)\n" +
538
		"	void foo(int value) { // X#foo(...)\n" +
539
		"	void foo(int value) { // X#foo(...)\n" +
539
		"	             ^^^^^\n" +
540
		"	             ^^^^^\n" +
540
		"The parameter value is never read\n" +
541
		"The parameter value is never used\n" +
541
		"----------\n" +
542
		"----------\n" +
542
		"2. ERROR in X.java (at line 7)\n" +
543
		"2. ERROR in X.java (at line 7)\n" +
543
		"	void bar(int value) { // X#bar(...)\n" +
544
		"	void bar(int value) { // X#bar(...)\n" +
544
		"	             ^^^^^\n" +
545
		"	             ^^^^^\n" +
545
		"The parameter value is never read\n" +
546
		"The parameter value is never used\n" +
546
		"----------\n" +
547
		"----------\n" +
547
		"3. ERROR in X.java (at line 24)\n" +
548
		"3. ERROR in X.java (at line 24)\n" +
548
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
549
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
549
		"	                ^^^^^\n" +
550
		"	                ^^^^^\n" +
550
		"The parameter value is never read\n" +
551
		"The parameter value is never used\n" +
551
		"----------\n",
552
		"----------\n",
552
		// javac options
553
		// javac options
553
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
554
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
Lines 605-636 Link Here
605
		"1. ERROR in X.java (at line 5)\n" +
606
		"1. ERROR in X.java (at line 5)\n" +
606
		"	void foo(int value) { // X#foo(...)\n" +
607
		"	void foo(int value) { // X#foo(...)\n" +
607
		"	             ^^^^^\n" +
608
		"	             ^^^^^\n" +
608
		"The parameter value is never read\n" +
609
		"The parameter value is never used\n" +
609
		"----------\n" +
610
		"----------\n" +
610
		"2. ERROR in X.java (at line 7)\n" +
611
		"2. ERROR in X.java (at line 7)\n" +
611
		"	void bar(int value) { // X#bar(...)\n" +
612
		"	void bar(int value) { // X#bar(...)\n" +
612
		"	             ^^^^^\n" +
613
		"	             ^^^^^\n" +
613
		"The parameter value is never read\n" +
614
		"The parameter value is never used\n" +
614
		"----------\n" +
615
		"----------\n" +
615
		"3. ERROR in X.java (at line 10)\n" +
616
		"3. ERROR in X.java (at line 10)\n" +
616
		"	void top(int value) { /* X#top(...)*/}\n" +
617
		"	void top(int value) { /* X#top(...)*/}\n" +
617
		"	             ^^^^^\n" +
618
		"	             ^^^^^\n" +
618
		"The parameter value is never read\n" +
619
		"The parameter value is never used\n" +
619
		"----------\n" +
620
		"----------\n" +
620
		"4. ERROR in X.java (at line 11)\n" +
621
		"4. ERROR in X.java (at line 11)\n" +
621
		"	void parent(int value) { /* X#parent(...) */}\n" +
622
		"	void parent(int value) { /* X#parent(...) */}\n" +
622
		"	                ^^^^^\n" +
623
		"	                ^^^^^\n" +
623
		"The parameter value is never read\n" +
624
		"The parameter value is never used\n" +
624
		"----------\n" +
625
		"----------\n" +
625
		"5. ERROR in X.java (at line 12)\n" +
626
		"5. ERROR in X.java (at line 12)\n" +
626
		"	public void doit(int value) { /* X#doit(...) */}\n" +
627
		"	public void doit(int value) { /* X#doit(...) */}\n" +
627
		"	                     ^^^^^\n" +
628
		"	                     ^^^^^\n" +
628
		"The parameter value is never read\n" +
629
		"The parameter value is never used\n" +
629
		"----------\n" +
630
		"----------\n" +
630
		"6. ERROR in X.java (at line 24)\n" +
631
		"6. ERROR in X.java (at line 24)\n" +
631
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
632
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
632
		"	                ^^^^^\n" +
633
		"	                ^^^^^\n" +
633
		"The parameter value is never read\n" +
634
		"The parameter value is never used\n" +
634
		"----------\n",
635
		"----------\n",
635
		// javac options
636
		// javac options
636
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
637
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
Lines 683-714 Link Here
683
		"1. ERROR in X.java (at line 3)\n" +
684
		"1. ERROR in X.java (at line 3)\n" +
684
		"	void foo(int value) { // X#foo(...)\n" +
685
		"	void foo(int value) { // X#foo(...)\n" +
685
		"	             ^^^^^\n" +
686
		"	             ^^^^^\n" +
686
		"The parameter value is never read\n" +
687
		"The parameter value is never used\n" +
687
		"----------\n" +
688
		"----------\n" +
688
		"2. ERROR in X.java (at line 5)\n" +
689
		"2. ERROR in X.java (at line 5)\n" +
689
		"	void bar(int value) { // X#bar(...)\n" +
690
		"	void bar(int value) { // X#bar(...)\n" +
690
		"	             ^^^^^\n" +
691
		"	             ^^^^^\n" +
691
		"The parameter value is never read\n" +
692
		"The parameter value is never used\n" +
692
		"----------\n" +
693
		"----------\n" +
693
		"3. ERROR in X.java (at line 9)\n" +
694
		"3. ERROR in X.java (at line 9)\n" +
694
		"	void top(int value) { /* X#top(...)*/}\n" +
695
		"	void top(int value) { /* X#top(...)*/}\n" +
695
		"	             ^^^^^\n" +
696
		"	             ^^^^^\n" +
696
		"The parameter value is never read\n" +
697
		"The parameter value is never used\n" +
697
		"----------\n" +
698
		"----------\n" +
698
		"4. ERROR in X.java (at line 11)\n" +
699
		"4. ERROR in X.java (at line 11)\n" +
699
		"	void parent(int value) { /* X#parent(...) */}\n" +
700
		"	void parent(int value) { /* X#parent(...) */}\n" +
700
		"	                ^^^^^\n" +
701
		"	                ^^^^^\n" +
701
		"The parameter value is never read\n" +
702
		"The parameter value is never used\n" +
702
		"----------\n" +
703
		"----------\n" +
703
		"5. ERROR in X.java (at line 13)\n" +
704
		"5. ERROR in X.java (at line 13)\n" +
704
		"	public void doit(int value) { /* X#doit(...) */}\n" +
705
		"	public void doit(int value) { /* X#doit(...) */}\n" +
705
		"	                     ^^^^^\n" +
706
		"	                     ^^^^^\n" +
706
		"The parameter value is never read\n" +
707
		"The parameter value is never used\n" +
707
		"----------\n" +
708
		"----------\n" +
708
		"6. ERROR in X.java (at line 21)\n" +
709
		"6. ERROR in X.java (at line 21)\n" +
709
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
710
		"	void parent(int value) { /* Parent#parent(...) */}\n" +
710
		"	                ^^^^^\n" +
711
		"	                ^^^^^\n" +
711
		"The parameter value is never read\n" +
712
		"The parameter value is never used\n" +
712
		"----------\n",
713
		"----------\n",
713
		// javac options
714
		// javac options
714
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
715
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java (-18 / +19 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 94-100 Link Here
94
		"1. WARNING in p1\\A.java (at line 3)\n" +
95
		"1. WARNING in p1\\A.java (at line 3)\n" +
95
		"	private int value;								\n" +
96
		"	private int value;								\n" +
96
		"	            ^^^^^\n" +
97
		"	            ^^^^^\n" +
97
		"The field A.value is never read locally\n" +
98
		"The private field A.value is never used\n" +
98
		"----------\n" +
99
		"----------\n" +
99
		"2. ERROR in p1\\A.java (at line 6)\n" +
100
		"2. ERROR in p1\\A.java (at line 6)\n" +
100
		"	value = 2;								\n" +
101
		"	value = 2;								\n" +
Lines 344-350 Link Here
344
		"1. WARNING in p1\\A.java (at line 3)\n" +
345
		"1. WARNING in p1\\A.java (at line 3)\n" +
345
		"	private String success = \"SUCCESS\";			\n" +
346
		"	private String success = \"SUCCESS\";			\n" +
346
		"	               ^^^^^^^\n" +
347
		"	               ^^^^^^^\n" +
347
		"The field A.success is never read locally\n" +
348
		"The private field A.success is never used\n" +
348
		"----------\n" +
349
		"----------\n" +
349
		"2. ERROR in p1\\A.java (at line 7)\n" +
350
		"2. ERROR in p1\\A.java (at line 7)\n" +
350
		"	public void aTask() {System.out.println(A.success);}\n" +
351
		"	public void aTask() {System.out.println(A.success);}\n" +
Lines 2263-2269 Link Here
2263
				"1. WARNING in com\\internap\\other\\ScopeExample.java (at line 4)\r\n" +
2264
				"1. WARNING in com\\internap\\other\\ScopeExample.java (at line 4)\r\n" +
2264
				"	private static final String LOGGER = \"FAILED\";\r\n" +
2265
				"	private static final String LOGGER = \"FAILED\";\r\n" +
2265
				"	                            ^^^^^^\n" +
2266
				"	                            ^^^^^^\n" +
2266
				"The field ScopeExample.LOGGER is never read locally\n" +
2267
				"The private field ScopeExample.LOGGER is never used\n" +
2267
				"----------\n" +
2268
				"----------\n" +
2268
				"2. ERROR in com\\internap\\other\\ScopeExample.java (at line 8)\r\n" +
2269
				"2. ERROR in com\\internap\\other\\ScopeExample.java (at line 8)\r\n" +
2269
				"	System.out.println(LOGGER);\r\n" +
2270
				"	System.out.println(LOGGER);\r\n" +
Lines 2654-2660 Link Here
2654
		"1. WARNING in X.java (at line 2)\n" +
2655
		"1. WARNING in X.java (at line 2)\n" +
2655
		"	private String value;\n" +
2656
		"	private String value;\n" +
2656
		"	               ^^^^^\n" +
2657
		"	               ^^^^^\n" +
2657
		"The field D.value is never read locally\n" +
2658
		"The private field D.value is never used\n" +
2658
		"----------\n" +
2659
		"----------\n" +
2659
		"2. ERROR in X.java (at line 13)\n" +
2660
		"2. ERROR in X.java (at line 13)\n" +
2660
		"	super(getValue());\n" +
2661
		"	super(getValue());\n" +
Lines 3264-3275 Link Here
3264
		"2. WARNING in B.java (at line 3)\n" + 
3265
		"2. WARNING in B.java (at line 3)\n" + 
3265
		"	public final String length = \"very long\";\n" + 
3266
		"	public final String length = \"very long\";\n" + 
3266
		"	                    ^^^^^^\n" + 
3267
		"	                    ^^^^^^\n" + 
3267
		"The field A.B.length is never read locally\n" + 
3268
		"The field A.B.length is never used locally\n" + 
3268
		"----------\n" + 
3269
		"----------\n" + 
3269
		"3. WARNING in B.java (at line 5)\n" + 
3270
		"3. WARNING in B.java (at line 5)\n" + 
3270
		"	private int [] B = new int[5];\n" + 
3271
		"	private int [] B = new int[5];\n" + 
3271
		"	               ^\n" + 
3272
		"	               ^\n" + 
3272
		"The field A.B is never read locally\n" + 
3273
		"The private field A.B is never used\n" + 
3273
		"----------\n" + 
3274
		"----------\n" + 
3274
		"4. ERROR in B.java (at line 9)\n" + 
3275
		"4. ERROR in B.java (at line 9)\n" + 
3275
		"	System.out.println(A.B.length);\n" + 
3276
		"	System.out.println(A.B.length);\n" + 
Lines 3298-3309 Link Here
3298
		"1. WARNING in B.java (at line 3)\n" + 
3299
		"1. WARNING in B.java (at line 3)\n" + 
3299
		"	private final String length = \"very long\";\n" + 
3300
		"	private final String length = \"very long\";\n" + 
3300
		"	                     ^^^^^^\n" + 
3301
		"	                     ^^^^^^\n" + 
3301
		"The field A.B.length is never read locally\n" + 
3302
		"The private field A.B.length is never used\n" + 
3302
		"----------\n" + 
3303
		"----------\n" + 
3303
		"2. WARNING in B.java (at line 5)\n" + 
3304
		"2. WARNING in B.java (at line 5)\n" + 
3304
		"	private int [] B = new int[5];\n" + 
3305
		"	private int [] B = new int[5];\n" + 
3305
		"	               ^\n" + 
3306
		"	               ^\n" + 
3306
		"The field A.B is never read locally\n" + 
3307
		"The private field A.B is never used\n" + 
3307
		"----------\n" + 
3308
		"----------\n" + 
3308
		"3. ERROR in B.java (at line 9)\n" + 
3309
		"3. ERROR in B.java (at line 9)\n" + 
3309
		"	System.out.println(A.B.length);\n" + 
3310
		"	System.out.println(A.B.length);\n" + 
Lines 3338-3354 Link Here
3338
		"1. WARNING in A.java (at line 2)\n" + 
3339
		"1. WARNING in A.java (at line 2)\n" + 
3339
		"	private int x;\n" + 
3340
		"	private int x;\n" + 
3340
		"	            ^\n" + 
3341
		"	            ^\n" + 
3341
		"The field A.x is never read locally\n" + 
3342
		"The private field A.x is never used\n" + 
3342
		"----------\n" + 
3343
		"----------\n" + 
3343
		"2. WARNING in A.java (at line 4)\n" + 
3344
		"2. WARNING in A.java (at line 4)\n" + 
3344
		"	private int x;\n" + 
3345
		"	private int x;\n" + 
3345
		"	            ^\n" + 
3346
		"	            ^\n" + 
3346
		"The field A.B.x is never read locally\n" + 
3347
		"The private field A.B.x is never used\n" + 
3347
		"----------\n" + 
3348
		"----------\n" + 
3348
		"3. WARNING in A.java (at line 5)\n" + 
3349
		"3. WARNING in A.java (at line 5)\n" + 
3349
		"	private C c = new C() {\n" + 
3350
		"	private C c = new C() {\n" + 
3350
		"	          ^\n" + 
3351
		"	          ^\n" + 
3351
		"The field A.B.c is never read locally\n" + 
3352
		"The private field A.B.c is never used\n" + 
3352
		"----------\n" + 
3353
		"----------\n" + 
3353
		"4. WARNING in A.java (at line 6)\n" + 
3354
		"4. WARNING in A.java (at line 6)\n" + 
3354
		"	void foo() {\n" + 
3355
		"	void foo() {\n" + 
Lines 3363-3369 Link Here
3363
		"6. WARNING in A.java (at line 12)\n" + 
3364
		"6. WARNING in A.java (at line 12)\n" + 
3364
		"	private int x;\n" + 
3365
		"	private int x;\n" + 
3365
		"	            ^\n" + 
3366
		"	            ^\n" + 
3366
		"The field A.C.x is never read locally\n" + 
3367
		"The private field A.C.x is never used\n" + 
3367
		"----------\n");
3368
		"----------\n");
3368
}
3369
}
3369
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956
3370
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956
Lines 3393-3409 Link Here
3393
		"1. WARNING in A.java (at line 2)\n" + 
3394
		"1. WARNING in A.java (at line 2)\n" + 
3394
		"	private int x;\n" + 
3395
		"	private int x;\n" + 
3395
		"	            ^\n" + 
3396
		"	            ^\n" + 
3396
		"The field A.x is never read locally\n" + 
3397
		"The private field A.x is never used\n" + 
3397
		"----------\n" + 
3398
		"----------\n" + 
3398
		"2. WARNING in A.java (at line 4)\n" + 
3399
		"2. WARNING in A.java (at line 4)\n" + 
3399
		"	private int x;\n" + 
3400
		"	private int x;\n" + 
3400
		"	            ^\n" + 
3401
		"	            ^\n" + 
3401
		"The field A.B.x is never read locally\n" + 
3402
		"The private field A.B.x is never used\n" + 
3402
		"----------\n" + 
3403
		"----------\n" + 
3403
		"3. WARNING in A.java (at line 5)\n" + 
3404
		"3. WARNING in A.java (at line 5)\n" + 
3404
		"	private C c = new C() {\n" + 
3405
		"	private C c = new C() {\n" + 
3405
		"	          ^\n" + 
3406
		"	          ^\n" + 
3406
		"The field A.B.c is never read locally\n" + 
3407
		"The private field A.B.c is never used\n" + 
3407
		"----------\n" + 
3408
		"----------\n" + 
3408
		"4. WARNING in A.java (at line 6)\n" + 
3409
		"4. WARNING in A.java (at line 6)\n" + 
3409
		"	void foo() {\n" + 
3410
		"	void foo() {\n" + 
Lines 3435-3446 Link Here
3435
		"1. WARNING in A.java (at line 2)\n" + 
3436
		"1. WARNING in A.java (at line 2)\n" + 
3436
		"	private int x;\n" + 
3437
		"	private int x;\n" + 
3437
		"	            ^\n" + 
3438
		"	            ^\n" + 
3438
		"The field A.x is never read locally\n" + 
3439
		"The private field A.x is never used\n" + 
3439
		"----------\n" + 
3440
		"----------\n" + 
3440
		"2. WARNING in A.java (at line 3)\n" + 
3441
		"2. WARNING in A.java (at line 3)\n" + 
3441
		"	private C c = new C() {\n" + 
3442
		"	private C c = new C() {\n" + 
3442
		"	          ^\n" + 
3443
		"	          ^\n" + 
3443
		"The field A.c is never read locally\n" + 
3444
		"The private field A.c is never used\n" + 
3444
		"----------\n" + 
3445
		"----------\n" + 
3445
		"3. WARNING in A.java (at line 4)\n" + 
3446
		"3. WARNING in A.java (at line 4)\n" + 
3446
		"	void foo() {\n" + 
3447
		"	void foo() {\n" + 
Lines 3455-3461 Link Here
3455
		"5. WARNING in A.java (at line 9)\n" + 
3456
		"5. WARNING in A.java (at line 9)\n" + 
3456
		"	private int x;\n" + 
3457
		"	private int x;\n" + 
3457
		"	            ^\n" + 
3458
		"	            ^\n" + 
3458
		"The field A.C.x is never read locally\n" + 
3459
		"The private field A.C.x is never used\n" + 
3459
		"----------\n");
3460
		"----------\n");
3460
}
3461
}
3461
public static Class testClass() {	return LookupTest.class;
3462
public static Class testClass() {	return LookupTest.class;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java (-2 / +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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 185-191 Link Here
185
		"3. WARNING in X.java (at line 6)\n" + 
186
		"3. WARNING in X.java (at line 6)\n" + 
186
		"	public int unusedField = 0;\n" + 
187
		"	public int unusedField = 0;\n" + 
187
		"	           ^^^^^^^^^^^\n" + 
188
		"	           ^^^^^^^^^^^\n" + 
188
		"The field X.M.unusedField is never read locally\n" + 
189
		"The field X.M.unusedField is never used locally\n" + 
189
		"----------\n" + 
190
		"----------\n" + 
190
		"4. WARNING in X.java (at line 7)\n" + 
191
		"4. WARNING in X.java (at line 7)\n" + 
191
		"	public class N {}\n" + 
192
		"	public class N {}\n" + 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (-7 / +414 lines)
Lines 7-25 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
13
import java.util.HashMap;
14
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.Map;
15
16
17
import junit.framework.Test;
18
16
import org.eclipse.jdt.core.JavaCore;
19
import org.eclipse.jdt.core.JavaCore;
17
import org.eclipse.jdt.core.compiler.CategorizedProblem;
20
import org.eclipse.jdt.core.compiler.CategorizedProblem;
18
import org.eclipse.jdt.internal.compiler.CompilationResult;
21
import org.eclipse.jdt.internal.compiler.CompilationResult;
19
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
22
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
23
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
24
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import junit.framework.Test;
23
25
24
/* Collects potential programming problems tests that are not segregated in a
26
/* Collects potential programming problems tests that are not segregated in a
25
 * dedicated test class (aka NullReferenceTest). */
27
 * dedicated test class (aka NullReferenceTest). */
Lines 143-149 Link Here
143
		"1. WARNING in X.java (at line 2)\r\n" +
145
		"1. WARNING in X.java (at line 2)\r\n" +
144
		"	public void foo(boolean b) {\r\n" +
146
		"	public void foo(boolean b) {\r\n" +
145
		"	                        ^\n" +
147
		"	                        ^\n" +
146
		"The parameter b is never read\n" +
148
		"The parameter b is never used\n" +
147
		"----------\n" /* expectedCompilerLog */,
149
		"----------\n" /* expectedCompilerLog */,
148
		"" /* expectedOutputString */,
150
		"" /* expectedOutputString */,
149
		false /* forceExecution */,
151
		false /* forceExecution */,
Lines 214-220 Link Here
214
		"1. WARNING in X.java (at line 3)\n" +
216
		"1. WARNING in X.java (at line 3)\n" +
215
		"	public void foo(boolean b) {\n" +
217
		"	public void foo(boolean b) {\n" +
216
		"	                        ^\n" +
218
		"	                        ^\n" +
217
		"The parameter b is never read\n" +
219
		"The parameter b is never used\n" +
218
		"----------\n" /* expectedCompilerLog */,
220
		"----------\n" /* expectedCompilerLog */,
219
		"" /* expectedOutputString */,
221
		"" /* expectedOutputString */,
220
		false /* forceExecution */,
222
		false /* forceExecution */,
Lines 279-285 Link Here
279
		"1. ERROR in X.java (at line 2)\r\n" +
281
		"1. ERROR in X.java (at line 2)\r\n" +
280
		"	public void foo(boolean b) {\r\n" +
282
		"	public void foo(boolean b) {\r\n" +
281
		"	                        ^\n" +
283
		"	                        ^\n" +
282
		"The parameter b is never read\n" +
284
		"The parameter b is never used\n" +
283
		"----------\n" /* expectedCompilerLog */,
285
		"----------\n" /* expectedCompilerLog */,
284
		"" /* expectedOutputString */,
286
		"" /* expectedOutputString */,
285
		false /* forceExecution */,
287
		false /* forceExecution */,
Lines 555-561 Link Here
555
		"1. WARNING in X.java (at line 3)\n" +
557
		"1. WARNING in X.java (at line 3)\n" +
556
		"	void foo(int unused) throws IOException {}\n" +
558
		"	void foo(int unused) throws IOException {}\n" +
557
		"	             ^^^^^^\n" +
559
		"	             ^^^^^^\n" +
558
		"The parameter unused is never read\n" +
560
		"The parameter unused is never used\n" +
559
		"----------\n" +
561
		"----------\n" +
560
		"2. ERROR in X.java (at line 3)\n" +
562
		"2. ERROR in X.java (at line 3)\n" +
561
		"	void foo(int unused) throws IOException {}\n" +
563
		"	void foo(int unused) throws IOException {}\n" +
Lines 594-600 Link Here
594
		"1. WARNING in X.java (at line 3)\n" +
596
		"1. WARNING in X.java (at line 3)\n" +
595
		"	void foo(int unused) throws IOException {}\n" +
597
		"	void foo(int unused) throws IOException {}\n" +
596
		"	             ^^^^^^\n" +
598
		"	             ^^^^^^\n" +
597
		"The parameter unused is never read\n" +
599
		"The parameter unused is never used\n" +
598
		"----------\n" +
600
		"----------\n" +
599
		"2. WARNING in X.java (at line 3)\n" +
601
		"2. WARNING in X.java (at line 3)\n" +
600
		"	void foo(int unused) throws IOException {}\n" +
602
		"	void foo(int unused) throws IOException {}\n" +
Lines 631-637 Link Here
631
		"1. ERROR in X.java (at line 2)\n" +
633
		"1. ERROR in X.java (at line 2)\n" +
632
		"	public X(boolean b) {\n" +
634
		"	public X(boolean b) {\n" +
633
		"	                 ^\n" +
635
		"	                 ^\n" +
634
		"The parameter b is never read\n" +
636
		"The parameter b is never used\n" +
635
		"----------\n" /* expectedCompilerLog */,
637
		"----------\n" /* expectedCompilerLog */,
636
		"" /* expectedOutputString */,
638
		"" /* expectedOutputString */,
637
		false /* forceExecution */,
639
		false /* forceExecution */,
Lines 1683-1686 Link Here
1683
		"The assignment to variable nvx has no effect\n" + 
1685
		"The assignment to variable nvx has no effect\n" + 
1684
		"----------\n");
1686
		"----------\n");
1685
}
1687
}
1688
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1689
public void test0046() {
1690
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1691
		return;
1692
	Map customOptions = getCompilerOptions();
1693
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1694
	this.runNegativeTest(
1695
			new String[] {
1696
				"X.java",
1697
				"class X {\n" + 
1698
				"    int foo() {\n" + 
1699
				"        int i=1;\n" + 
1700
				"        boolean b=false;\n" + 
1701
				"        b|=true;\n" + 			// not a relevant usage
1702
				"        int k = 2;\n" + 
1703
				"        --k;\n" + 				// not a relevant usage
1704
				"        k+=3;\n" + 			// not a relevant usage
1705
				"        Integer j = 3;\n" + 
1706
				"        j++;\n" + 				// relevant because unboxing is involved
1707
				"        return i++;\n" + 		// value after increment is used
1708
				"    }\n" + 
1709
				"}"
1710
			},
1711
			"----------\n" + 
1712
			"1. WARNING in X.java (at line 4)\n" + 
1713
			"	boolean b=false;\n" + 
1714
			"	        ^\n" + 
1715
			"The local variable b is never used\n" + 
1716
			"----------\n" + 
1717
			"2. WARNING in X.java (at line 6)\n" + 
1718
			"	int k = 2;\n" + 
1719
			"	    ^\n" + 
1720
			"The local variable k is never used\n" + 
1721
			"----------\n",
1722
			null/*classLibraries*/,
1723
			true/*shouldFlushOutputDirectory*/,
1724
			customOptions);
1725
}
1726
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1727
// variant with private fields instead of locals
1728
public void test0046_field() {
1729
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1730
		return;
1731
	Map customOptions = getCompilerOptions();
1732
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1733
	this.runNegativeTest(
1734
			new String[] {
1735
				"X.java",
1736
				"class X {\n" + 
1737
				"    private int i=1;\n" + 
1738
				"    private boolean b=false;\n" + 
1739
				"    private int k = 2;\n" + 
1740
				"    private Integer j = 3;\n" + 
1741
				"    int foo() {\n" + 
1742
				"        b|=true;\n" + 			// not a relevant usage
1743
				"        --k;\n" + 				// not a relevant usage
1744
				"        k+=3;\n" + 			// not a relevant usage
1745
				"        j++;\n" + 				// relevant because unboxing is involved
1746
				"        return i++;\n" + 		// value after increment is used
1747
				"    }\n" + 
1748
				"}"
1749
			},
1750
			"----------\n" + 
1751
			"1. WARNING in X.java (at line 3)\n" + 
1752
			"	private boolean b=false;\n" + 
1753
			"	                ^\n" + 
1754
			"The private field X.b is never used\n" + 
1755
			"----------\n" + 
1756
			"2. WARNING in X.java (at line 4)\n" + 
1757
			"	private int k = 2;\n" + 
1758
			"	            ^\n" + 
1759
			"The private field X.k is never used\n" + 
1760
			"----------\n",
1761
			null/*classLibraries*/,
1762
			true/*shouldFlushOutputDirectory*/,
1763
			customOptions);
1764
}
1765
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1766
// variant with private fields instead of locals - this-qualified access
1767
public void test0046_field_this_qualified() {
1768
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1769
		return;
1770
	Map customOptions = getCompilerOptions();
1771
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1772
	this.runNegativeTest(
1773
			new String[] {
1774
				"X.java",
1775
				"class X {\n" + 
1776
				"    private int i=1;\n" + 
1777
				"    private boolean b=false;\n" + 
1778
				"    private int k = 2;\n" + 
1779
				"    private Integer j = 3;\n" + 
1780
				"    int foo() {\n" + 
1781
				"        this.b|=true;\n" + 		// not a relevant usage
1782
				"        --this.k;\n" + 			// not a relevant usage
1783
				"        getThis().k+=3;\n" + 		// not a relevant usage
1784
				"        this.j++;\n" + 			// relevant because unboxing is involved
1785
				"        return this.i++;\n" + 		// value after increment is used
1786
				"    }\n" +
1787
				"    X getThis() { return this; }\n" + 
1788
				"}"
1789
			},
1790
			"----------\n" + 
1791
			"1. WARNING in X.java (at line 3)\n" + 
1792
			"	private boolean b=false;\n" + 
1793
			"	                ^\n" + 
1794
			"The private field X.b is never used\n" + 
1795
			"----------\n" + 
1796
			"2. WARNING in X.java (at line 4)\n" + 
1797
			"	private int k = 2;\n" + 
1798
			"	            ^\n" + 
1799
			"The private field X.k is never used\n" + 
1800
			"----------\n",
1801
			null/*classLibraries*/,
1802
			true/*shouldFlushOutputDirectory*/,
1803
			customOptions);
1804
}
1805
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1806
// variant with private fields instead of locals - regular qualified access
1807
public void test0046_field_qualified() {
1808
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1809
		return;
1810
	Map customOptions = getCompilerOptions();
1811
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1812
	this.runNegativeTest(
1813
			new String[] {
1814
				"X.java",
1815
				"class X {\n" + 
1816
				"    private int i=1;\n" + 
1817
				"    private boolean b=false;\n" + 
1818
				"    private int k = 2;\n" + 
1819
				"    private Integer j = 3;\n" + 
1820
				"    int foo(X that) {\n" + 
1821
				"        that.b|=true;\n" + 		// not a relevant usage
1822
				"        --that.k;\n" + 			// not a relevant usage
1823
				"        that.k+=3;\n" + 			// not a relevant usage
1824
				"        that.j++;\n" + 			// relevant because unboxing is involved
1825
				"        return that.i++;\n" + 		// value after increment is used
1826
				"    }\n" + 
1827
				"}"
1828
			},
1829
			"----------\n" + 
1830
			"1. WARNING in X.java (at line 3)\n" + 
1831
			"	private boolean b=false;\n" + 
1832
			"	                ^\n" + 
1833
			"The private field X.b is never used\n" + 
1834
			"----------\n" + 
1835
			"2. WARNING in X.java (at line 4)\n" + 
1836
			"	private int k = 2;\n" + 
1837
			"	            ^\n" + 
1838
			"The private field X.k is never used\n" + 
1839
			"----------\n",
1840
			null/*classLibraries*/,
1841
			true/*shouldFlushOutputDirectory*/,
1842
			customOptions);
1843
}
1844
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1845
// variant with fields inside a private type
1846
public void test0046_field_in_private_type() {
1847
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1848
		return;
1849
	Map customOptions = getCompilerOptions();
1850
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1851
	this.runNegativeTest(
1852
			new String[] {
1853
				"X.java",
1854
				"class X {\n" +
1855
				"    private class Y {\n" + 
1856
				"        int i=1;\n" + 
1857
				"        public boolean b=false;\n" + 
1858
				"        protected int k = 2;\n" + 
1859
				"        Integer j = 3;\n" +
1860
				"    }\n" + 
1861
				"    int foo(Y y) {\n" + 
1862
				"        y.b|=true;\n" + 		// not a relevant usage
1863
				"        --y.k;\n" + 			// not a relevant usage
1864
				"        y.k+=3;\n" + 			// not a relevant usage
1865
				"        y.j++;\n" + 			// relevant because unboxing is involved
1866
				"        return y.i++;\n" + 	// value after increment is used
1867
				"    }\n" + 
1868
				"}"
1869
			},
1870
			"----------\n" + 
1871
			"1. WARNING in X.java (at line 4)\n" + 
1872
			"	public boolean b=false;\n" + 
1873
			"	               ^\n" + 
1874
			"The field X.Y.b is never used locally\n" + 
1875
			"----------\n" + 
1876
			"2. WARNING in X.java (at line 5)\n" + 
1877
			"	protected int k = 2;\n" + 
1878
			"	              ^\n" + 
1879
			"The field X.Y.k is never used locally\n" + 
1880
			"----------\n",
1881
			null/*classLibraries*/,
1882
			true/*shouldFlushOutputDirectory*/,
1883
			customOptions);
1884
}
1885
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1886
public void test0047() {
1887
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1888
		return;
1889
	Map customOptions = getCompilerOptions();
1890
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
1891
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1892
	this.runNegativeTest(
1893
			new String[] {
1894
				"X.java",
1895
				"class X {\n" + 
1896
				"    void foo(int param1, int param2, Integer param3) {\n" + 
1897
				"        boolean b=false;\n" + 
1898
				"        b|=true;\n" + 			// not a relevant usage
1899
				"        param1++;\n" + 		// not a relevant usage
1900
				"        param2 += 1;\n" + 		// not a relevant usage
1901
				"        param3++;\n" + 		// relevant because unboxing is involved
1902
				"    }\n" + 
1903
				"}"
1904
			},
1905
			"----------\n" + 
1906
			"1. WARNING in X.java (at line 2)\n" + 
1907
			"	void foo(int param1, int param2, Integer param3) {\n" + 
1908
			"	             ^^^^^^\n" + 
1909
			"The parameter param1 is never used\n" + 
1910
			"----------\n" + 
1911
			"2. WARNING in X.java (at line 2)\n" + 
1912
			"	void foo(int param1, int param2, Integer param3) {\n" + 
1913
			"	                         ^^^^^^\n" + 
1914
			"The parameter param2 is never used\n" + 
1915
			"----------\n" + 
1916
			"3. WARNING in X.java (at line 3)\n" + 
1917
			"	boolean b=false;\n" + 
1918
			"	        ^\n" + 
1919
			"The local variable b is never used\n" + 
1920
			"----------\n",
1921
			null/*classLibraries*/,
1922
			true/*shouldFlushOutputDirectory*/,
1923
			customOptions);
1924
}
1925
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1926
// To verify that unused parameter warning is not shown for an implementing method's parameter when
1927
// CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract is disabled
1928
public void test0048() {
1929
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1930
		return;
1931
	Map customOptions = getCompilerOptions();
1932
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
1933
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
1934
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
1935
	this.runNegativeTest(
1936
			new String[] {
1937
				"X.java",
1938
				"public class X extends A implements Y{\n" + 
1939
				"   public void foo(int param1, int param2, Integer param3) {\n" + // implementing method, so dont warn
1940
				"        boolean b=false;\n" + 
1941
				"        b|=true;\n" + 			// not a relevant usage
1942
				"        param1++;\n" + 		// not a relevant usage
1943
				"        param2 += 1;\n" + 		// not a relevant usage
1944
				"        param3++;\n" + 		// relevant because unboxing is involved
1945
				"    }\n" + 
1946
				"   public void foo(int param1, int param2) {\n" + // warn
1947
				"        boolean b=false;\n" + 
1948
				"        b|=true;\n" + 			// not a relevant usage
1949
				"        param1++;\n" + 		// not a relevant usage
1950
				"        param2 += 1;\n" + 		// not a relevant usage
1951
				"    }\n" +
1952
				"   public void bar(int param1, int param2, Integer param3) {\n" + // implementing method, so dont warn
1953
				"        param1++;\n" + 		// not a relevant usage
1954
				"        param2 += 1;\n" + 		// not a relevant usage
1955
				"        param3++;\n" + 		// relevant because unboxing is involved
1956
				"    }\n" +
1957
				"}\n" +
1958
				"interface Y{\n" +
1959
				"	public void foo(int param1, int param2, Integer param3);" +
1960
				"}\n" +
1961
				"abstract class A{\n" +
1962
				"	public abstract void bar(int param1, int param2, Integer param3);" +
1963
				"}\n"
1964
			},
1965
			"----------\n" + 
1966
			"1. WARNING in X.java (at line 3)\n" + 
1967
			"	boolean b=false;\n" + 
1968
			"	        ^\n" + 
1969
			"The local variable b is never used\n" + 
1970
			"----------\n" + 
1971
			"2. WARNING in X.java (at line 9)\n" + 
1972
			"	public void foo(int param1, int param2) {\n" + 
1973
			"	                    ^^^^^^\n" + 
1974
			"The parameter param1 is never used\n" + 
1975
			"----------\n" + 
1976
			"3. WARNING in X.java (at line 9)\n" + 
1977
			"	public void foo(int param1, int param2) {\n" + 
1978
			"	                                ^^^^^^\n" + 
1979
			"The parameter param2 is never used\n" + 
1980
			"----------\n" + 
1981
			"4. WARNING in X.java (at line 10)\n" + 
1982
			"	boolean b=false;\n" + 
1983
			"	        ^\n" + 
1984
			"The local variable b is never used\n" + 
1985
			"----------\n",
1986
			null/*classLibraries*/,
1987
			true/*shouldFlushOutputDirectory*/,
1988
			customOptions);
1989
}
1990
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
1991
// To verify that unused parameter warning is not shown for an overriding method's parameter when
1992
// CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete is disabled
1993
public void test0049() {
1994
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
1995
		return;
1996
	Map customOptions = getCompilerOptions();
1997
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
1998
	customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
1999
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
2000
	this.runNegativeTest(
2001
			new String[] {
2002
				"X.java",
2003
				"public class X extends A {\n" + 
2004
				"   public void foo(int param1, int param2, Integer param3) {\n" + // overriding method, so dont warn
2005
				"        boolean b=false;\n" + 
2006
				"        b|=true;\n" + 			// not a relevant usage
2007
				"        param1++;\n" + 		// not a relevant usage
2008
				"        param2 += 1;\n" + 		// not a relevant usage
2009
				"        param3++;\n" + 		// relevant because unboxing is involved
2010
				"    }\n" + 
2011
				"   public void foo(int param1, Integer param3) {\n" + // overriding method, so dont warn
2012
				"        param1++;\n" + 		// not a relevant usage
2013
				"        param3++;\n" + 		// relevant because unboxing is involved
2014
				"    }\n" + 
2015
				"}\n" +
2016
				"class A{\n" +
2017
				"   public void foo(int param1, int param2, Integer param3) {\n" +
2018
				"        param1 -=1;\n" + 		// not a relevant usage
2019
				"        param2--;\n" + 		// not a relevant usage
2020
				"        param3--;\n" + 		// relevant because unboxing is involved
2021
				"    }\n" + 
2022
				"}\n"
2023
			},
2024
			"----------\n" + 
2025
			"1. WARNING in X.java (at line 3)\n" + 
2026
			"	boolean b=false;\n" + 
2027
			"	        ^\n" + 
2028
			"The local variable b is never used\n" + 
2029
			"----------\n" + 
2030
			"2. WARNING in X.java (at line 9)\n" + 
2031
			"	public void foo(int param1, Integer param3) {\n" + 
2032
			"	                    ^^^^^^\n" + 
2033
			"The parameter param1 is never used\n" + 
2034
			"----------\n" + 
2035
			"3. WARNING in X.java (at line 15)\n" + 
2036
			"	public void foo(int param1, int param2, Integer param3) {\n" + 
2037
			"	                    ^^^^^^\n" + 
2038
			"The parameter param1 is never used\n" + 
2039
			"----------\n" + 
2040
			"4. WARNING in X.java (at line 15)\n" + 
2041
			"	public void foo(int param1, int param2, Integer param3) {\n" + 
2042
			"	                                ^^^^^^\n" + 
2043
			"The parameter param2 is never used\n" + 
2044
			"----------\n",
2045
			null/*classLibraries*/,
2046
			true/*shouldFlushOutputDirectory*/,
2047
			customOptions);
2048
}
2049
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682
2050
// To verify that unused local warning is not shown for locals declared in unreachable code
2051
public void test0050() {
2052
	if (this.complianceLevel < ClassFileConstants.JDK1_5)
2053
		return;
2054
	Map customOptions = getCompilerOptions();
2055
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
2056
	this.runNegativeTest(
2057
			new String[] {
2058
				"X.java",
2059
				"class X {\n" + 
2060
				"    int foo() {\n" + 
2061
				"        int i=1;\n" +
2062
				"		 if (false) {\n" + 
2063
				"        	boolean b=false;\n" + // don't complain as unused
2064
				"        	b|=true;\n" +
2065
				"		 }\n" + 			// not a relevant usage
2066
				"        int k = 2;\n" + 
2067
				"        --k;\n" + 			// not a relevant usage
2068
				"        k+=3;\n" + 		// not a relevant usage
2069
				"        Integer j = 3;\n" + 
2070
				"        j++;\n" + 			// relevant because unboxing is involved
2071
				"        return i++;\n" + 	// value after increment is used
2072
				"    }\n" + 
2073
				"}"
2074
			},
2075
			"----------\n" + 
2076
			"1. WARNING in X.java (at line 4)\n" + 
2077
			"	if (false) {\n" + 
2078
			"        	boolean b=false;\n" + 
2079
			"        	b|=true;\n" + 
2080
			"		 }\n" + 
2081
			"	           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
2082
			"Dead code\n" + 
2083
			"----------\n" + 
2084
			"2. WARNING in X.java (at line 8)\n" + 
2085
			"	int k = 2;\n" + 
2086
			"	    ^\n" + 
2087
			"The local variable k is never used\n" + 
2088
			"----------\n",
2089
			null/*classLibraries*/,
2090
			true/*shouldFlushOutputDirectory*/,
2091
			customOptions);
2092
}
1686
}
2093
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java (-1 / +2 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 660-666 Link Here
660
			"1. WARNING in bug\\C.java (at line 3)\n" +
661
			"1. WARNING in bug\\C.java (at line 3)\n" +
661
			"	private static B b;\n" +
662
			"	private static B b;\n" +
662
			"	                 ^\n" +
663
			"	                 ^\n" +
663
			"The field C.b is never read locally\n" +
664
			"The private field C.b is never used\n" +
664
			"----------\n");
665
			"----------\n");
665
	}
666
	}
666
667

Return to bug 185682