Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 181419 Details for
Bug 185682
Increment/decrement operators mark local variables as read
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch v7
bug_185682_v7.patch (text/plain), 91.30 KB, created by
Stephan Herrmann
on 2010-10-21 12:25:20 EDT
(
hide
)
Description:
patch v7
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2010-10-21 12:25:20 EDT
Size:
91.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.222 >diff -u -r1.222 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 7 Sep 2010 13:39:18 -0000 1.222 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 21 Oct 2010 16:10:06 -0000 >@@ -117,6 +117,7 @@ > * MissingSynchronizedModifierInInheritedMethod > * Stephan Herrmann - added the following constants > * UnusedObjectAllocation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -359,6 +360,8 @@ > int DuplicateBlankFinalFieldInitialization = FieldRelated + 82; > /** @since 3.6 */ > int UnresolvedVariable = FieldRelated + 83; >+ /** @since 3.7 */ >+ int UnusedScopedField = Internal + FieldRelated + 84; > > // variable hiding > /** @since 3.0 */ >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v >retrieving revision 1.103 >diff -u -r1.103 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 10 May 2010 20:47:58 -0000 1.103 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 21 Oct 2010 16:10:08 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > * Matt McCutchen - partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995 > * Karen Moore - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=207411 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -357,11 +358,17 @@ > return this; > } > >- public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, boolean isStrictlyAssigned) { >- // ignore references insing Javadoc comments >- if ((this.bits & ASTNode.InsideJavadoc) == 0 && !isStrictlyAssigned && field.isOrEnclosedByPrivateType() && !scope.isDefinedInField(field)) { >- // ignore cases where field is used from inside itself >- field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, int filteredBits) { >+ if ((this.bits & ASTNode.InsideJavadoc) == 0 // ignore references inside Javadoc comments >+ && (filteredBits & IsStrictlyAssigned) == 0 // ignore write access >+ && field.isOrEnclosedByPrivateType() >+ && !scope.isDefinedInField(field)) // ignore cases where field is used from inside itself >+ { >+ if (((filteredBits & IsCompoundAssigned) != 0)) >+ // used, but usage may not be relevant >+ field.original().compoundUseFlag++; >+ else >+ field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; > } > > if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v >retrieving revision 1.129 >diff -u -r1.129 FieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 21 Feb 2010 03:31:46 -0000 1.129 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 21 Oct 2010 16:10:09 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -290,6 +291,8 @@ > > public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { > boolean isStatic; >+ // check if compound assignment is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, this.binding, valueRequired); > FieldBinding codegenBinding = this.binding.original(); > this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic())); > if (isStatic) { >@@ -337,6 +340,8 @@ > > public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { > boolean isStatic; >+ // check if postIncrement is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, this.binding, valueRequired); > FieldBinding codegenBinding = this.binding.original(); > this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic())); > if (isStatic) { >@@ -577,7 +582,7 @@ > if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it > this.bits |= NeedReceiverGenericCast; > } >- if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0)) { >+ if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) { > scope.problemReporter().deprecatedField(fieldBinding, this); > } > boolean isImplicitThisRcv = this.receiver.isImplicitThis(); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java,v >retrieving revision 1.31 >diff -u -r1.31 JavadocFieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 24 Nov 2008 10:21:23 -0000 1.31 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 21 Oct 2010 16:10:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -97,7 +98,7 @@ > } > this.binding = (FieldBinding) fieldBinding; > >- if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { >+ if (isFieldUseDeprecated(this.binding, scope, this.bits)) { > scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); > } > return this.resolvedType = this.binding.type; >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v >retrieving revision 1.147 >diff -u -r1.147 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 21 Sep 2010 14:02:57 -0000 1.147 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 21 Oct 2010 16:10:12 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -380,6 +381,8 @@ > > public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { > FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); >+ // check if compound assignment is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, lastFieldBinding, valueRequired); > boolean isFirst = lastFieldBinding == this.binding > && (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType()) > && this.otherBindings == null; // could be dup: next.next.next >@@ -431,6 +434,8 @@ > > public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { > FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); >+ // check if this post increment is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, lastFieldBinding, valueRequired); > boolean isFirst = lastFieldBinding == this.binding > && (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType()) > && this.otherBindings == null; // could be dup: next.next.next >@@ -719,7 +724,7 @@ > } > } > // only last field is actually a write access if any >- if (isFieldUseDeprecated(field, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0 && index+1 == length)) { >+ if (isFieldUseDeprecated(field, scope, index+1 == length ? this.bits : 0)) { > scope.problemReporter().deprecatedField(field, this); > } > // constant propagation can only be performed as long as the previous one is a constant too. >@@ -954,7 +959,7 @@ > && (!fieldBinding.isStatic() || methodScope.isStatic)) { > scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding); > } >- if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) != 0 && this.indexOfFirstFieldBinding == this.tokens.length)) { >+ if (isFieldUseDeprecated(fieldBinding, scope, this.indexOfFirstFieldBinding == this.tokens.length ? this.bits : 0)) { > scope.problemReporter().deprecatedField(fieldBinding, this); > } > if (fieldBinding.isStatic()) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java,v >retrieving revision 1.32 >diff -u -r1.32 Reference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java 7 Mar 2009 01:08:07 -0000 1.32 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java 21 Oct 2010 16:10:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -15,8 +16,11 @@ > import org.eclipse.jdt.internal.compiler.flow.FlowContext; > import org.eclipse.jdt.internal.compiler.flow.FlowInfo; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >+import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; >+import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >+import org.eclipse.jdt.internal.compiler.lookup.MethodScope; > import org.eclipse.jdt.internal.compiler.lookup.Scope; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >@@ -87,4 +91,59 @@ > public abstract void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired); > > public abstract void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired); >+ >+/* report if a private field is only read from a 'special operator', >+ * i.e., in a postIncrement expression or a compound assignment, >+ * where the information is never flowing out off the field. */ >+void reportOnlyUselesslyReadPrivateField(BlockScope currentScope, FieldBinding fieldBinding, boolean valueRequired) { >+ if (valueRequired) { >+ // turn compound use into real use: >+ fieldBinding.compoundUseFlag = 0; >+ fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >+ } else { >+ if (fieldBinding.isUsedOnlyInCompound()) { >+ fieldBinding.compoundUseFlag--; // consume one >+ if (fieldBinding.compoundUseFlag == 0 // report only the last usage >+ && fieldBinding.isOrEnclosedByPrivateType() >+ && (this.implicitConversion & TypeIds.UNBOXING) == 0) // don't report if unboxing is involved (might cause NPE) >+ { >+ // compoundAssignment/postIncrement is the only usage of this field >+ currentScope.problemReporter().unusedPrivateField(fieldBinding.sourceField()); >+ fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // don't report again >+ } >+ } >+ } >+} >+/* report a local/arg that is only read from a 'special operator', >+ * i.e., in a postIncrement expression or a compound assignment, >+ * where the information is never flowing out off the local/arg. */ >+static void reportOnlyUselesslyReadLocal(BlockScope currentScope, LocalVariableBinding localBinding) { >+ if (localBinding.declaration == null) >+ return; // secret local >+ if ((localBinding.declaration.bits & ASTNode.IsLocalDeclarationReachable) == 0) >+ return; // declaration is unreachable >+ if (localBinding.declaration instanceof Argument) { >+ // check compiler options to report against unused arguments >+ MethodScope methodScope = currentScope.methodScope(); >+ if (methodScope != null) { >+ MethodBinding method = ((AbstractMethodDeclaration)methodScope.referenceContext()).binding; >+ >+ boolean shouldReport = !method.isMain(); >+ if (method.isImplementing()) { >+ shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenImplementingAbstract; >+ } else if (method.isOverriding()) { >+ shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenOverridingConcrete; >+ } >+ >+ if (shouldReport) { >+ // report the case of an argument that is unread except through a special operator >+ currentScope.problemReporter().unusedArgument(localBinding.declaration); >+ } >+ } >+ } else { >+ // report the case of a local variable that is unread except for a special operator >+ currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); >+ } >+ localBinding.useFlag = LocalVariableBinding.USED; // don't report again >+} > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.124 >diff -u -r1.124 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 23 Sep 2010 12:03:42 -0000 1.124 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 21 Oct 2010 16:10:13 -0000 >@@ -7,7 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment, >+ * Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -78,10 +79,16 @@ > currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); > // we could improve error msg here telling "cannot use compound assignment on final local variable" > } >- if (isReachable) { >- localBinding.useFlag = LocalVariableBinding.USED; >- } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) { >- localBinding.useFlag = LocalVariableBinding.FAKE_USED; >+ if (localBinding.useFlag != LocalVariableBinding.USED) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+ // access from compound assignment does not prevent "unused" warning, unless unboxing is involved: >+ if (isReachable && (this.implicitConversion & TypeIds.UNBOXING) != 0) { >+ localBinding.useFlag = LocalVariableBinding.USED; >+ } else { >+ // use values < 0 to count the number of compound uses: >+ if (localBinding.useFlag <= LocalVariableBinding.UNUSED) >+ localBinding.useFlag--; >+ } > } > } > } >@@ -204,7 +211,7 @@ > } > } > >- if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0)) >+ if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) > scope.problemReporter().deprecatedField(fieldBinding, this); > > if ((this.bits & ASTNode.IsStrictlyAssigned) == 0 >@@ -462,6 +469,21 @@ > * are optimized in one access: e.g "a = a + 1" optimized into "a++". > */ > public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+ switch (this.bits & ASTNode.RestrictiveFlagMASK) { >+ case Binding.LOCAL: >+ LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; >+ if (localBinding.useFlag < LocalVariableBinding.USED) { >+ if (!valueRequired && localBinding.useFlag == -1) >+ // compound assignment is the only usage of this local >+ Reference.reportOnlyUselesslyReadLocal(currentScope, localBinding); >+ localBinding.useFlag++; >+ } >+ break; >+ case Binding.FIELD: >+ // check if compound assignment is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, (FieldBinding)this.binding, valueRequired); >+ } > this.generateCompoundAssignment( > currentScope, > codeStream, >@@ -599,7 +621,10 @@ > public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { > switch (this.bits & ASTNode.RestrictiveFlagMASK) { > case Binding.FIELD : // assigning to a field >- FieldBinding codegenField = (((FieldBinding)this.binding).original()); >+ FieldBinding fieldBinding = (FieldBinding)this.binding; >+ // check if postIncrement is the only usage of a private field >+ reportOnlyUselesslyReadPrivateField(currentScope, fieldBinding, valueRequired); >+ FieldBinding codegenField = fieldBinding.original(); > if (codegenField.isStatic()) { > if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) { > TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */); >@@ -662,6 +687,14 @@ > return; > case Binding.LOCAL : // assigning to a local variable > LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+ if (localBinding.useFlag < LocalVariableBinding.USED) { >+ if (!valueRequired && localBinding.useFlag == -1) >+ // postIncrement is the only usage of this local >+ Reference.reportOnlyUselesslyReadLocal(currentScope, localBinding); >+ localBinding.useFlag++; >+ } >+ > // using incr bytecode if possible > if (localBinding.type == TypeBinding.INT) { > if (valueRequired) { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java,v >retrieving revision 1.59 >diff -u -r1.59 FieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 11 Nov 2009 05:40:46 -0000 1.59 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 21 Oct 2010 16:10:14 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.lookup; > >@@ -19,6 +20,8 @@ > > public class FieldBinding extends VariableBinding { > public ReferenceBinding declaringClass; >+ public int compoundUseFlag = 0; // number or accesses via postIncrement or compoundAssignment >+ > protected FieldBinding() { > super(null, null, 0, null); > // for creating problem field >@@ -332,7 +335,13 @@ > */ > > public final boolean isUsed() { >- return (this.modifiers & ExtraCompilerModifiers.AccLocallyUsed) != 0; >+ return (this.modifiers & ExtraCompilerModifiers.AccLocallyUsed) != 0 || this.compoundUseFlag > 0; >+} >+/* Answer true if the only use of this field is in compound assignment or post increment >+ */ >+ >+public final boolean isUsedOnlyInCompound() { >+ return (this.modifiers & ExtraCompilerModifiers.AccLocallyUsed) == 0 && this.compoundUseFlag > 0; > } > /* Answer true if the receiver has protected visibility > */ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java,v >retrieving revision 1.47 >diff -u -r1.47 LocalVariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 18 Mar 2009 00:18:35 -0000 1.47 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 21 Oct 2010 16:10:14 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.lookup; > >@@ -26,7 +27,7 @@ > public static final int UNUSED = 0; > public static final int USED = 1; > public static final int FAKE_USED = 2; >- public int useFlag; // for flow analysis (default is UNUSED) >+ public int useFlag; // for flow analysis (default is UNUSED), values < 0 indicate the number of compound uses (postIncrement or compoundAssignment) > > public BlockScope declaringScope; // back-pointer to its declaring scope > public LocalDeclaration declaration; // for source-positions >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.422 >diff -u -r1.422 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 21 Sep 2010 14:02:58 -0000 1.422 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 21 Oct 2010 16:10:27 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.problem; > >@@ -194,6 +195,7 @@ > case IProblem.UnusedPrivateConstructor: > case IProblem.UnusedPrivateMethod: > case IProblem.UnusedPrivateField: >+ case IProblem.UnusedScopedField: > case IProblem.UnusedPrivateType: > return CompilerOptions.UnusedPrivateMember; > >@@ -7246,7 +7248,10 @@ > } > public void unusedPrivateField(FieldDeclaration fieldDecl) { > >- int severity = computeSeverity(IProblem.UnusedPrivateField); >+ int problemId = (fieldDecl.modifiers & ClassFileConstants.AccPrivate) != 0 >+ ? IProblem.UnusedPrivateField >+ : IProblem.UnusedScopedField; >+ int severity = computeSeverity(problemId); > if (severity == ProblemSeverities.Ignore) return; > > FieldBinding field = fieldDecl.binding; >@@ -7265,7 +7270,7 @@ > return; // do not report unused serialPersistentFields field > } > this.handle( >- IProblem.UnusedPrivateField, >+ problemId, > new String[] { > new String(field.declaringClass.readableName()), > new String(field.name), >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.258 >diff -u -r1.258 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 7 Sep 2010 13:39:18 -0000 1.258 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 21 Oct 2010 16:10:28 -0000 >@@ -8,6 +8,7 @@ > # Contributors: > # IBM Corporation - initial API and implementation > # Benjamin Muskalla - Contribution for bug 239066 >+# Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > ############################################################################### > 0 = {0} > 1 = super cannot be used in java.lang.Object >@@ -49,8 +50,8 @@ > 58 = The final local variable {0} cannot be assigned. It must be blank and not using a compound assignment > 59 = The parameter {0} should not be assigned > 60 = The final local variable {0} cannot be assigned, since it is defined in an enclosing type >-61 = The local variable {0} is never read >-62 = The parameter {0} is never read >+61 = The local variable {0} is never used >+62 = The parameter {0} is never used > 63 = The code of method {0}({1}) is exceeding the 65535 bytes limit > 64 = The code for the static initializer is exceeding the 65535 bytes limit > 65 = Too many parameters, parameter {0} is exceeding the limit of 255 words eligible for method parameters >@@ -65,13 +66,14 @@ > 74 = Cannot make a static reference to the non-static field {0} > 75 = Cannot reference a field before it is defined > 76 = The static field {0}.{1} should be accessed in a static way >-77 = The field {0}.{1} is never read locally >+77 = The private field {0}.{1} is never used > 78 = The static field {0}.{1} should be accessed directly > 79 = Unqualified access to the field {0}.{1} > 80 = The final field {0}.{1} cannot be assigned > 81 = The blank final field {0} may not have been initialized > 82 = The final field {0} may already have been assigned > 83 = {0} cannot be resolved to a variable >+84 = The field {0}.{1} is never used locally > > 90 = The local variable {0} is hiding another local variable defined in an enclosing type scope > 91 = The local variable {0} is hiding a field from type {1} >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java,v >retrieving revision 1.46 >diff -u -r1.46 CodeSnippetFieldReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java 7 Mar 2009 01:08:09 -0000 1.46 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java 21 Oct 2010 16:10:30 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.eval; > >@@ -325,7 +326,7 @@ > return null; > } > >- if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) !=0)) { >+ if (isFieldUseDeprecated(this.binding, scope, this.bits)) { > scope.problemReporter().deprecatedField(this.binding, this); > } > // check for this.x in static is done in the resolution of the receiver >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java,v >retrieving revision 1.59 >diff -u -r1.59 CodeSnippetQualifiedNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 18 Nov 2008 20:23:11 -0000 1.59 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 21 Oct 2010 16:10:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.eval; > >@@ -463,7 +464,7 @@ > } > } > // only last field is actually a write access if any >- if (isFieldUseDeprecated((FieldBinding) this.binding, scope, (this.bits & IsStrictlyAssigned) !=0 && this.indexOfFirstFieldBinding == length)) { >+ if (isFieldUseDeprecated((FieldBinding) this.binding, scope, this.indexOfFirstFieldBinding == length ? this.bits : 0)) { > scope.problemReporter().deprecatedField((FieldBinding) this.binding, this); > } > } >@@ -510,7 +511,7 @@ > } > if (field.isValidBinding()) { > // only last field is actually a write access if any >- if (isFieldUseDeprecated(field, scope, (this.bits & IsStrictlyAssigned) !=0 && index+1 == length)) { >+ if (isFieldUseDeprecated(field, scope, index+1 == length ? this.bits : 0)) { > scope.problemReporter().deprecatedField(field, this); > } > // constant propagation can only be performed as long as the previous one is a constant too. >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java,v >retrieving revision 1.58 >diff -u -r1.58 CodeSnippetSingleNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 7 Mar 2009 00:59:03 -0000 1.58 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 21 Oct 2010 16:10:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.internal.eval; > >@@ -101,7 +102,7 @@ > } > this.constant = fieldBinding.constant(); > >- if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & IsStrictlyAssigned) !=0)) { >+ if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) { > scope.problemReporter().deprecatedField(fieldBinding, this); > } > return fieldBinding.type; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.218 >diff -u -r1.218 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 22 Jun 2010 02:31:11 -0000 1.218 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 21 Oct 2010 16:10:54 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Stephan Herrmann - Contribution for bug 295551 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -9355,7 +9356,7 @@ > "1. ERROR in A.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field A.i is never read locally\n" + >+ "The private field A.i is never used\n" + > "----------\n"; > runNegativeTest( > true, >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java,v >retrieving revision 1.65 >diff -u -r1.65 AssignmentTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 21 Jan 2010 16:48:42 -0000 1.65 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 21 Oct 2010 16:10:57 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -223,12 +224,12 @@ > "1. WARNING in X.java (at line 4)\n" + > " private final Object o;\n" + > " ^\n" + >- "The field X.Test1.o is never read locally\n" + >+ "The private field X.Test1.o is never used\n" + > "----------\n" + > "2. WARNING in X.java (at line 13)\n" + > " private final Object o;\n" + > " ^\n" + >- "The field X.Test2.o is never read locally\n" + >+ "The private field X.Test2.o is never used\n" + > "----------\n" + > "3. ERROR in X.java (at line 25)\n" + > " System.out.println(o); // illegal; o is not definitely assigned\n" + >@@ -238,7 +239,7 @@ > "4. WARNING in X.java (at line 42)\n" + > " private final Object o;\n" + > " ^\n" + >- "The field X.Test5.o is never read locally\n" + >+ "The private field X.Test5.o is never used\n" + > "----------\n" + > "5. ERROR in X.java (at line 44)\n" + > " Test5() {\n" + >@@ -253,7 +254,7 @@ > "7. WARNING in X.java (at line 52)\n" + > " private final Object o;\n" + > " ^\n" + >- "The field X.Test6.o is never read locally\n" + >+ "The private field X.Test6.o is never used\n" + > "----------\n" + > "8. ERROR in X.java (at line 59)\n" + > " other.o = new Object(); // illegal! other.o is not assignable\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.215 >diff -u -r1.215 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 6 Oct 2010 13:57:31 -0000 1.215 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 21 Oct 2010 16:11:14 -0000 >@@ -10,6 +10,7 @@ > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 > * Stephan Herrmann - Contribution for bug 295551 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -2879,7 +2880,7 @@ > "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" + > " final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" + > " ^^\n" + >- "The local variable l1 is never read\n" + >+ "The local variable l1 is never used\n" + > "----------\n" + > "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" + > " final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" + >@@ -3059,7 +3060,7 @@ > "7. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" + > " final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" + > " ^^\n" + >- "The local variable l1 is never read\n" + >+ "The local variable l1 is never used\n" + > "----------\n" + > "8. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/Z.java (at line 58)\n" + > " final XX<?, XY> l1 = (XX<?, XY>) i.getKey();\n" + >@@ -6228,7 +6229,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "2 problems (2 warnings)", > true); >@@ -6315,7 +6316,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -6347,7 +6348,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "2 problems (2 warnings)", > true); >@@ -6374,7 +6375,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -6400,7 +6401,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -6431,7 +6432,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "2 problems (2 warnings)", > true); >@@ -6463,7 +6464,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " String u;\n" + > " ^\n" + >- "The local variable u is never read\n" + >+ "The local variable u is never used\n" + > "----------\n" + > "2 problems (2 warnings)", > true); >@@ -7564,7 +7565,7 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -7627,7 +7628,7 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -7637,7 +7638,7 @@ > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -7682,7 +7683,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -7787,7 +7788,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -7942,7 +7943,7 @@ > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -7992,7 +7993,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -8002,7 +8003,7 @@ > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -8057,7 +8058,7 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -8067,7 +8068,7 @@ > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -8117,7 +8118,7 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -8172,7 +8173,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -8182,7 +8183,7 @@ > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -8237,12 +8238,12 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " this.<String>bar();\n" + >@@ -8297,7 +8298,7 @@ > "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private void foo(int i) throws java.io.IOException {\n" + >@@ -8307,7 +8308,7 @@ > "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + > " int j;\n" + > " ^\n" + >- "The local variable j is never read\n" + >+ "The local variable j is never used\n" + > "----------\n" + > "6. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" + > " next: for (;;) {\n" + >@@ -8380,7 +8381,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " public void foo(int i) {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -8471,7 +8472,7 @@ > "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " public void foo(int i) {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "2 problems (2 warnings)", > true); >@@ -8497,7 +8498,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " public void foo(int i) {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -8979,7 +8980,7 @@ > "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + > " public void foo(int i) {\n" + > " ^\n" + >- "The parameter i is never read\n" + >+ "The parameter i is never used\n" + > "----------\n" + > "1 problem (1 warning)", > true); >@@ -11334,7 +11335,7 @@ > "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field X.i is never read locally\n" + >+ "The private field X.i is never used\n" + > "----------\n" + > "2 problems (1 error, 1 warning)", > true); >@@ -11374,7 +11375,7 @@ > "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field X.i is never read locally\n" + >+ "The private field X.i is never used\n" + > "----------\n" + > "1 problem (1 error)", > true); >@@ -11397,7 +11398,7 @@ > "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field X.i is never read locally\n" + >+ "The private field X.i is never used\n" + > "----------\n" + > "1 problem (1 error)", > true); >@@ -11425,7 +11426,7 @@ > "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field X.i is never read locally\n" + >+ "The private field X.i is never used\n" + > "----------\n" + > "2 problems (1 error, 1 warning)", > true); >@@ -11448,7 +11449,7 @@ > "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + >- "The field X.i is never read locally\n" + >+ "The private field X.i is never used\n" + > "----------\n" + > "1 problem (1 error)", > true); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.37 >diff -u -r1.37 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 7 Sep 2010 13:39:17 -0000 1.37 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 21 Oct 2010 16:11:19 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -848,6 +849,7 @@ > expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); >+ expectedProblemAttributes.put("UnusedScopedField", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); >@@ -1482,6 +1484,7 @@ > expectedProblemAttributes.put("UnusedObjectAllocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_OBJECT_ALLOCATION)); > expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER)); > expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER)); >+ expectedProblemAttributes.put("UnusedScopedField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER)); > expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER)); > expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER)); > expectedProblemAttributes.put("UnusedTypeArgumentsForConstructorInvocation", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_TYPE_ARGUMENTS_FOR_METHOD_INVOCATION)); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java,v >retrieving revision 1.71 >diff -u -r1.71 JavadocBugsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 18 Mar 2010 16:22:36 -0000 1.71 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 21 Oct 2010 16:11:30 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -7190,12 +7191,12 @@ > "1. WARNING in X.java (at line 2)\n" + > " private int unused1;\n" + > " ^^^^^^^\n" + >- "The field X.unused1 is never read locally\n" + >+ "The private field X.unused1 is never used\n" + > "----------\n" + > "2. WARNING in X.java (at line 7)\n" + > " private int unused2;\n" + > " ^^^^^^^\n" + >- "The field X.unused2 is never read locally\n" + >+ "The private field X.unused2 is never used\n" + > "----------\n", > null, null, > JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings >Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java,v >retrieving revision 1.51 >diff -u -r1.51 JavadocTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java 11 May 2010 18:53:50 -0000 1.51 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java 21 Oct 2010 16:11:31 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -279,7 +280,7 @@ > "1. WARNING in test\\AbstractVisibility.java (at line 5)\n" + > " public int avf_public = avf_private;\n" + > " ^^^^^^^^^^\n" + >- "The field AbstractVisibility.AvcPrivate.avf_public is never read locally\n" + >+ "The field AbstractVisibility.AvcPrivate.avf_public is never used locally\n" + > "----------\n" + > "2. WARNING in test\\AbstractVisibility.java (at line 10)\n" + > " public int avm_public() {\n" + >@@ -290,7 +291,7 @@ > "1. WARNING in test\\Visibility.java (at line 5)\n" + > " public int vf_public = vf_private;\n" + > " ^^^^^^^^^\n" + >- "The field Visibility.VcPrivate.vf_public is never read locally\n" + >+ "The field Visibility.VcPrivate.vf_public is never used locally\n" + > "----------\n" + > "2. WARNING in test\\Visibility.java (at line 11)\n" + > " public int vm_public() {\n" + >@@ -301,7 +302,7 @@ > "1. WARNING in test\\copy\\VisibilityPackage.java (at line 5)\n" + > " public int vf_public = vf_private;\n" + > " ^^^^^^^^^\n" + >- "The field VisibilityPackage.VpPrivate.vf_public is never read locally\n" + >+ "The field VisibilityPackage.VpPrivate.vf_public is never used locally\n" + > "----------\n" + > "2. WARNING in test\\copy\\VisibilityPackage.java (at line 10)\n" + > " public int vm_public() {\n" + >@@ -312,7 +313,7 @@ > "1. WARNING in test\\copy\\VisibilityPublic.java (at line 5)\n" + > " public int vf_public = vf_private;\n" + > " ^^^^^^^^^\n" + >- "The field VisibilityPublic.VpPrivate.vf_public is never read locally\n" + >+ "The field VisibilityPublic.VpPrivate.vf_public is never used locally\n" + > "----------\n" + > "2. WARNING in test\\copy\\VisibilityPublic.java (at line 10)\n" + > " public int vm_public() {\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java,v >retrieving revision 1.18 >diff -u -r1.18 LocalVariableTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java 27 Jun 2008 16:04:44 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java 21 Oct 2010 16:11:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -411,7 +412,7 @@ > "1. ERROR in X.java (at line 7)\n" + > " void bar(int value) { // X#bar(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n", > // javac options > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); >@@ -469,17 +470,17 @@ > "1. ERROR in X.java (at line 5)\n" + > " void foo(int value) { // X#foo(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 7)\n" + > " void bar(int value) { // X#bar(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "3. ERROR in X.java (at line 24)\n" + > " void parent(int value) { /* Parent#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n", > // javac options > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); >@@ -537,17 +538,17 @@ > "1. ERROR in X.java (at line 5)\n" + > " void foo(int value) { // X#foo(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 7)\n" + > " void bar(int value) { // X#bar(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "3. ERROR in X.java (at line 24)\n" + > " void parent(int value) { /* Parent#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n", > // javac options > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); >@@ -605,32 +606,32 @@ > "1. ERROR in X.java (at line 5)\n" + > " void foo(int value) { // X#foo(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 7)\n" + > " void bar(int value) { // X#bar(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "3. ERROR in X.java (at line 10)\n" + > " void top(int value) { /* X#top(...)*/}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "4. ERROR in X.java (at line 11)\n" + > " void parent(int value) { /* X#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "5. ERROR in X.java (at line 12)\n" + > " public void doit(int value) { /* X#doit(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "6. ERROR in X.java (at line 24)\n" + > " void parent(int value) { /* Parent#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n", > // javac options > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); >@@ -683,32 +684,32 @@ > "1. ERROR in X.java (at line 3)\n" + > " void foo(int value) { // X#foo(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 5)\n" + > " void bar(int value) { // X#bar(...)\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "3. ERROR in X.java (at line 9)\n" + > " void top(int value) { /* X#top(...)*/}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "4. ERROR in X.java (at line 11)\n" + > " void parent(int value) { /* X#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "5. ERROR in X.java (at line 13)\n" + > " public void doit(int value) { /* X#doit(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n" + > "6. ERROR in X.java (at line 21)\n" + > " void parent(int value) { /* Parent#parent(...) */}\n" + > " ^^^^^\n" + >- "The parameter value is never read\n" + >+ "The parameter value is never used\n" + > "----------\n", > // javac options > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v >retrieving revision 1.86 >diff -u -r1.86 LookupTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 13 Jul 2010 03:55:58 -0000 1.86 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 21 Oct 2010 16:11:36 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -94,7 +95,7 @@ > "1. WARNING in p1\\A.java (at line 3)\n" + > " private int value; \n" + > " ^^^^^\n" + >- "The field A.value is never read locally\n" + >+ "The private field A.value is never used\n" + > "----------\n" + > "2. ERROR in p1\\A.java (at line 6)\n" + > " value = 2; \n" + >@@ -344,7 +345,7 @@ > "1. WARNING in p1\\A.java (at line 3)\n" + > " private String success = \"SUCCESS\"; \n" + > " ^^^^^^^\n" + >- "The field A.success is never read locally\n" + >+ "The private field A.success is never used\n" + > "----------\n" + > "2. ERROR in p1\\A.java (at line 7)\n" + > " public void aTask() {System.out.println(A.success);}\n" + >@@ -2263,7 +2264,7 @@ > "1. WARNING in com\\internap\\other\\ScopeExample.java (at line 4)\r\n" + > " private static final String LOGGER = \"FAILED\";\r\n" + > " ^^^^^^\n" + >- "The field ScopeExample.LOGGER is never read locally\n" + >+ "The private field ScopeExample.LOGGER is never used\n" + > "----------\n" + > "2. ERROR in com\\internap\\other\\ScopeExample.java (at line 8)\r\n" + > " System.out.println(LOGGER);\r\n" + >@@ -2654,7 +2655,7 @@ > "1. WARNING in X.java (at line 2)\n" + > " private String value;\n" + > " ^^^^^\n" + >- "The field D.value is never read locally\n" + >+ "The private field D.value is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 13)\n" + > " super(getValue());\n" + >@@ -3264,12 +3265,12 @@ > "2. WARNING in B.java (at line 3)\n" + > " public final String length = \"very long\";\n" + > " ^^^^^^\n" + >- "The field A.B.length is never read locally\n" + >+ "The field A.B.length is never used locally\n" + > "----------\n" + > "3. WARNING in B.java (at line 5)\n" + > " private int [] B = new int[5];\n" + > " ^\n" + >- "The field A.B is never read locally\n" + >+ "The private field A.B is never used\n" + > "----------\n" + > "4. ERROR in B.java (at line 9)\n" + > " System.out.println(A.B.length);\n" + >@@ -3298,12 +3299,12 @@ > "1. WARNING in B.java (at line 3)\n" + > " private final String length = \"very long\";\n" + > " ^^^^^^\n" + >- "The field A.B.length is never read locally\n" + >+ "The private field A.B.length is never used\n" + > "----------\n" + > "2. WARNING in B.java (at line 5)\n" + > " private int [] B = new int[5];\n" + > " ^\n" + >- "The field A.B is never read locally\n" + >+ "The private field A.B is never used\n" + > "----------\n" + > "3. ERROR in B.java (at line 9)\n" + > " System.out.println(A.B.length);\n" + >@@ -3338,17 +3339,17 @@ > "1. WARNING in A.java (at line 2)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.x is never read locally\n" + >+ "The private field A.x is never used\n" + > "----------\n" + > "2. WARNING in A.java (at line 4)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.B.x is never read locally\n" + >+ "The private field A.B.x is never used\n" + > "----------\n" + > "3. WARNING in A.java (at line 5)\n" + > " private C c = new C() {\n" + > " ^\n" + >- "The field A.B.c is never read locally\n" + >+ "The private field A.B.c is never used\n" + > "----------\n" + > "4. WARNING in A.java (at line 6)\n" + > " void foo() {\n" + >@@ -3363,7 +3364,7 @@ > "6. WARNING in A.java (at line 12)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.C.x is never read locally\n" + >+ "The private field A.C.x is never used\n" + > "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956 >@@ -3393,17 +3394,17 @@ > "1. WARNING in A.java (at line 2)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.x is never read locally\n" + >+ "The private field A.x is never used\n" + > "----------\n" + > "2. WARNING in A.java (at line 4)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.B.x is never read locally\n" + >+ "The private field A.B.x is never used\n" + > "----------\n" + > "3. WARNING in A.java (at line 5)\n" + > " private C c = new C() {\n" + > " ^\n" + >- "The field A.B.c is never read locally\n" + >+ "The private field A.B.c is never used\n" + > "----------\n" + > "4. WARNING in A.java (at line 6)\n" + > " void foo() {\n" + >@@ -3435,12 +3436,12 @@ > "1. WARNING in A.java (at line 2)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.x is never read locally\n" + >+ "The private field A.x is never used\n" + > "----------\n" + > "2. WARNING in A.java (at line 3)\n" + > " private C c = new C() {\n" + > " ^\n" + >- "The field A.c is never read locally\n" + >+ "The private field A.c is never used\n" + > "----------\n" + > "3. WARNING in A.java (at line 4)\n" + > " void foo() {\n" + >@@ -3455,7 +3456,7 @@ > "5. WARNING in A.java (at line 9)\n" + > " private int x;\n" + > " ^\n" + >- "The field A.C.x is never read locally\n" + >+ "The private field A.C.x is never used\n" + > "----------\n"); > } > public static Class testClass() { return LookupTest.class; >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java,v >retrieving revision 1.24 >diff -u -r1.24 ProblemConstructorTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java 28 Apr 2009 17:17:33 -0000 1.24 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java 21 Oct 2010 16:11:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -185,7 +186,7 @@ > "3. WARNING in X.java (at line 6)\n" + > " public int unusedField = 0;\n" + > " ^^^^^^^^^^^\n" + >- "The field X.M.unusedField is never read locally\n" + >+ "The field X.M.unusedField is never used locally\n" + > "----------\n" + > "4. WARNING in X.java (at line 7)\n" + > " public class N {}\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v >retrieving revision 1.25 >diff -u -r1.25 ProgrammingProblemsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 23 Sep 2010 12:03:44 -0000 1.25 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 21 Oct 2010 16:11:39 -0000 >@@ -7,19 +7,21 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > > import java.util.HashMap; > import java.util.Map; > >+import junit.framework.Test; >+ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.internal.compiler.CompilationResult; > import org.eclipse.jdt.internal.compiler.ICompilerRequestor; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >-import junit.framework.Test; > > /* Collects potential programming problems tests that are not segregated in a > * dedicated test class (aka NullReferenceTest). */ >@@ -34,7 +36,7 @@ > // Only the highest compliance level is run; add the VM argument > // -Dcompliance=1.4 (for example) to lower it if needed > static { >-// TESTS_NAMES = new String[] { "test001" }; >+// TESTS_NAMES = new String[] { "test0046" }; > // TESTS_NUMBERS = new int[] { 43 }; > // TESTS_RANGE = new int[] { 1, -1 }; > } >@@ -143,7 +145,7 @@ > "1. WARNING in X.java (at line 2)\r\n" + > " public void foo(boolean b) {\r\n" + > " ^\n" + >- "The parameter b is never read\n" + >+ "The parameter b is never used\n" + > "----------\n" /* expectedCompilerLog */, > "" /* expectedOutputString */, > false /* forceExecution */, >@@ -214,7 +216,7 @@ > "1. WARNING in X.java (at line 3)\n" + > " public void foo(boolean b) {\n" + > " ^\n" + >- "The parameter b is never read\n" + >+ "The parameter b is never used\n" + > "----------\n" /* expectedCompilerLog */, > "" /* expectedOutputString */, > false /* forceExecution */, >@@ -279,7 +281,7 @@ > "1. ERROR in X.java (at line 2)\r\n" + > " public void foo(boolean b) {\r\n" + > " ^\n" + >- "The parameter b is never read\n" + >+ "The parameter b is never used\n" + > "----------\n" /* expectedCompilerLog */, > "" /* expectedOutputString */, > false /* forceExecution */, >@@ -555,7 +557,7 @@ > "1. WARNING in X.java (at line 3)\n" + > " void foo(int unused) throws IOException {}\n" + > " ^^^^^^\n" + >- "The parameter unused is never read\n" + >+ "The parameter unused is never used\n" + > "----------\n" + > "2. ERROR in X.java (at line 3)\n" + > " void foo(int unused) throws IOException {}\n" + >@@ -594,7 +596,7 @@ > "1. WARNING in X.java (at line 3)\n" + > " void foo(int unused) throws IOException {}\n" + > " ^^^^^^\n" + >- "The parameter unused is never read\n" + >+ "The parameter unused is never used\n" + > "----------\n" + > "2. WARNING in X.java (at line 3)\n" + > " void foo(int unused) throws IOException {}\n" + >@@ -631,7 +633,7 @@ > "1. ERROR in X.java (at line 2)\n" + > " public X(boolean b) {\n" + > " ^\n" + >- "The parameter b is never read\n" + >+ "The parameter b is never used\n" + > "----------\n" /* expectedCompilerLog */, > "" /* expectedOutputString */, > false /* forceExecution */, >@@ -1683,4 +1685,411 @@ > "The assignment to variable nvx has no effect\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+public void test0046() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " int foo() {\n" + >+ " int i=1;\n" + >+ " boolean b=false;\n" + >+ " b|=true;\n" + // not a relevant usage >+ " int k = 2;\n" + >+ " --k;\n" + // not a relevant usage >+ " k+=3;\n" + // not a relevant usage >+ " Integer j = 3;\n" + >+ " j++;\n" + // relevant because unboxing is involved >+ " i++;\n" + >+ " return i++;\n" + // value after increment is used >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " boolean b=false;\n" + >+ " ^\n" + >+ "The local variable b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " int k = 2;\n" + >+ " ^\n" + >+ "The local variable k is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// variant with private fields instead of locals >+public void test0046_field() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " private int i=1;\n" + >+ " private boolean b=false;\n" + >+ " private int k = 2;\n" + >+ " private Integer j = 3;\n" + >+ " int foo() {\n" + >+ " b|=true;\n" + // not a relevant usage >+ " --k;\n" + // not a relevant usage >+ " k+=3;\n" + // not a relevant usage >+ " j++;\n" + // relevant because unboxing is involved >+ " return i++;\n" + // value after increment is used >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " private boolean b=false;\n" + >+ " ^\n" + >+ "The private field X.b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " private int k = 2;\n" + >+ " ^\n" + >+ "The private field X.k is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// variant with private fields instead of locals - this-qualified access >+public void test0046_field_this_qualified() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " private int i=1;\n" + >+ " private boolean b=false;\n" + >+ " private int k = 2;\n" + >+ " private Integer j = 3;\n" + >+ " int foo() {\n" + >+ " this.b|=true;\n" + // not a relevant usage >+ " --this.k;\n" + // not a relevant usage >+ " getThis().k+=3;\n" + // not a relevant usage >+ " this.j++;\n" + // relevant because unboxing is involved >+ " return this.i++;\n" + // value after increment is used >+ " }\n" + >+ " X getThis() { return this; }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " private boolean b=false;\n" + >+ " ^\n" + >+ "The private field X.b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " private int k = 2;\n" + >+ " ^\n" + >+ "The private field X.k is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// variant with private fields instead of locals - regular qualified access >+public void test0046_field_qualified() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " private int i=1;\n" + >+ " private boolean b=false;\n" + >+ " private int k = 2;\n" + >+ " private Integer j = 3;\n" + >+ " int foo(X that) {\n" + >+ " that.b|=true;\n" + // not a relevant usage >+ " --that.k;\n" + // not a relevant usage >+ " that.k+=3;\n" + // not a relevant usage >+ " that.j++;\n" + // relevant because unboxing is involved >+ "that.i++;\n"+ >+ " return that.i++;\n" + // value after increment is used >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " private boolean b=false;\n" + >+ " ^\n" + >+ "The private field X.b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " private int k = 2;\n" + >+ " ^\n" + >+ "The private field X.k is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// variant with fields inside a private type >+public void test0046_field_in_private_type() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " private class Y {\n" + >+ " int i=1;\n" + >+ " public boolean b=false;\n" + >+ " protected int k = 2;\n" + >+ " Integer j = 3;\n" + >+ " }\n" + >+ " int foo(Y y) {\n" + >+ " y.b|=true;\n" + // not a relevant usage >+ " --y.k;\n" + // not a relevant usage >+ " y.k+=3;\n" + // not a relevant usage >+ " y.j++;\n" + // relevant because unboxing is involved >+ " return y.i++;\n" + // value after increment is used >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " public boolean b=false;\n" + >+ " ^\n" + >+ "The field X.Y.b is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " protected int k = 2;\n" + >+ " ^\n" + >+ "The field X.Y.k is never used locally\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+public void test0047() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " void foo(int param1, int param2, Integer param3) {\n" + >+ " boolean b=false;\n" + >+ " b|=true;\n" + // not a relevant usage >+ " param1++;\n" + // not a relevant usage >+ " param2 += 1;\n" + // not a relevant usage >+ " param3++;\n" + // relevant because unboxing is involved >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " void foo(int param1, int param2, Integer param3) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param1 is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 2)\n" + >+ " void foo(int param1, int param2, Integer param3) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param2 is never used\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 3)\n" + >+ " boolean b=false;\n" + >+ " ^\n" + >+ "The local variable b is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// To verify that unused parameter warning is not shown for an implementing method's parameter when >+// CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract is disabled >+public void test0048() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X extends A implements Y{\n" + >+ " public void foo(int param1, int param2, Integer param3) {\n" + // implementing method, so dont warn >+ " boolean b=false;\n" + >+ " b|=true;\n" + // not a relevant usage >+ " param1++;\n" + // not a relevant usage >+ " param2 += 1;\n" + // not a relevant usage >+ " param3++;\n" + // relevant because unboxing is involved >+ " }\n" + >+ " public void foo(int param1, int param2) {\n" + // warn >+ " boolean b=false;\n" + >+ " b|=true;\n" + // not a relevant usage >+ " param1++;\n" + // not a relevant usage >+ " param2 += 1;\n" + // not a relevant usage >+ " }\n" + >+ " public void bar(int param1, int param2, Integer param3) {\n" + // implementing method, so dont warn >+ " param1++;\n" + // not a relevant usage >+ " param2 += 1;\n" + // not a relevant usage >+ " param3++;\n" + // relevant because unboxing is involved >+ " }\n" + >+ "}\n" + >+ "interface Y{\n" + >+ " public void foo(int param1, int param2, Integer param3);" + >+ "}\n" + >+ "abstract class A{\n" + >+ " public abstract void bar(int param1, int param2, Integer param3);" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " boolean b=false;\n" + >+ " ^\n" + >+ "The local variable b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 9)\n" + >+ " public void foo(int param1, int param2) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param1 is never used\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " public void foo(int param1, int param2) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param2 is never used\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 10)\n" + >+ " boolean b=false;\n" + >+ " ^\n" + >+ "The local variable b is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// To verify that unused parameter warning is not shown for an overriding method's parameter when >+// CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete is disabled >+public void test0049() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X extends A {\n" + >+ " public void foo(int param1, int param2, Integer param3) {\n" + // overriding method, so dont warn >+ " boolean b=false;\n" + >+ " b|=true;\n" + // not a relevant usage >+ " param1++;\n" + // not a relevant usage >+ " param2 += 1;\n" + // not a relevant usage >+ " param3++;\n" + // relevant because unboxing is involved >+ " }\n" + >+ " public void foo(int param1, Integer param3) {\n" + // overriding method, so dont warn >+ " param1++;\n" + // not a relevant usage >+ " param3++;\n" + // relevant because unboxing is involved >+ " }\n" + >+ "}\n" + >+ "class A{\n" + >+ " public void foo(int param1, int param2, Integer param3) {\n" + >+ " param1 -=1;\n" + // not a relevant usage >+ " param2--;\n" + // not a relevant usage >+ " param3--;\n" + // relevant because unboxing is involved >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 3)\n" + >+ " boolean b=false;\n" + >+ " ^\n" + >+ "The local variable b is never used\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 9)\n" + >+ " public void foo(int param1, Integer param3) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param1 is never used\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 15)\n" + >+ " public void foo(int param1, int param2, Integer param3) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param1 is never used\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 15)\n" + >+ " public void foo(int param1, int param2, Integer param3) {\n" + >+ " ^^^^^^\n" + >+ "The parameter param2 is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185682 >+// To verify that unused local warning is not shown for locals declared in unreachable code >+public void test0050() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " int foo() {\n" + >+ " int i=1;\n" + >+ " if (false) {\n" + >+ " boolean b=false;\n" + // don't complain as unused >+ " b|=true;\n" + >+ " }\n" + // not a relevant usage >+ " int k = 2;\n" + >+ " --k;\n" + // not a relevant usage >+ " k+=3;\n" + // not a relevant usage >+ " Integer j = 3;\n" + >+ " j++;\n" + // relevant because unboxing is involved >+ " return i++;\n" + // value after increment is used >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " if (false) {\n" + >+ " boolean b=false;\n" + >+ " b|=true;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 8)\n" + >+ " int k = 2;\n" + >+ " ^\n" + >+ "The local variable k is never used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} > } >\ No newline at end of file >Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v >retrieving revision 1.79 >diff -u -r1.79 StaticImportTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 15 Apr 2010 15:18:23 -0000 1.79 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 21 Oct 2010 16:11:42 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -660,7 +661,7 @@ > "1. WARNING in bug\\C.java (at line 3)\n" + > " private static B b;\n" + > " ^\n" + >- "The field C.b is never read locally\n" + >+ "The private field C.b is never used\n" + > "----------\n"); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 185682
:
174421
|
178716
|
178806
|
181232
|
181235
|
181303
|
181409
|
181419
|
181439
|
181481
|
181557