### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v retrieving revision 1.117 diff -u -r1.117 Expression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 27 May 2008 22:21:13 -0000 1.117 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 4 Jun 2008 17:22:14 -0000 @@ -749,6 +749,40 @@ } } +public static Binding getDirectBinding(Expression someExpression) { + if ((someExpression.bits & ASTNode.IgnoreNoEffectAssignCheck) != 0) { + return null; + } + if (someExpression instanceof SingleNameReference) { + return ((SingleNameReference)someExpression).binding; + } else if (someExpression instanceof FieldReference) { + FieldReference fieldRef = (FieldReference)someExpression; + if (fieldRef.receiver.isThis() && !(fieldRef.receiver instanceof QualifiedThisReference)) { + return fieldRef.binding; + } + } else if (someExpression instanceof Assignment) { + Expression lhs = ((Assignment)someExpression).lhs; + if ((lhs.bits & ASTNode.IsStrictlyAssigned) != 0) { + // i = i = ...; // eq to int i = ...; + return getDirectBinding (((Assignment)someExpression).lhs); + } else if (someExpression instanceof PrefixExpression) { + // i = i++; // eq to ++i; + return getDirectBinding (((Assignment)someExpression).lhs); + } + } else if (someExpression instanceof QualifiedNameReference) { + QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) someExpression; + if (qualifiedNameReference.indexOfFirstFieldBinding != 1 + && qualifiedNameReference.otherBindings == null) { + // case where a static field is retrieved using ClassName.fieldname + return qualifiedNameReference.binding; + } + } +// } else if (someExpression instanceof PostfixExpression) { // recurse for postfix: i++ --> i +// // note: "b = b++" is equivalent to doing nothing, not to "b++" +// return getDirectBinding(((PostfixExpression) someExpression).lhs); + return null; +} + public boolean isCompactableOperation() { return false; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java,v retrieving revision 1.82 diff -u -r1.82 Assignment.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 27 May 2008 22:21:13 -0000 1.82 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 4 Jun 2008 17:22:13 -0000 @@ -98,40 +98,6 @@ codeStream.recordPositionsFrom(pc, this.sourceStart); } -public static Binding getDirectBinding(Expression someExpression) { - if ((someExpression.bits & ASTNode.IgnoreNoEffectAssignCheck) != 0) { - return null; - } - if (someExpression instanceof SingleNameReference) { - return ((SingleNameReference)someExpression).binding; - } else if (someExpression instanceof FieldReference) { - FieldReference fieldRef = (FieldReference)someExpression; - if (fieldRef.receiver.isThis() && !(fieldRef.receiver instanceof QualifiedThisReference)) { - return fieldRef.binding; - } - } else if (someExpression instanceof Assignment) { - Expression lhs = ((Assignment)someExpression).lhs; - if ((lhs.bits & ASTNode.IsStrictlyAssigned) != 0) { - // i = i = ...; // eq to int i = ...; - return getDirectBinding (((Assignment)someExpression).lhs); - } else if (someExpression instanceof PrefixExpression) { - // i = i++; // eq to ++i; - return getDirectBinding (((Assignment)someExpression).lhs); - } - } else if (someExpression instanceof QualifiedNameReference) { - QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) someExpression; - if (qualifiedNameReference.indexOfFirstFieldBinding != 1 - && qualifiedNameReference.otherBindings == null) { - // case where a static field is retrieved using ClassName.fieldname - return qualifiedNameReference.binding; - } - } -// } else if (someExpression instanceof PostfixExpression) { // recurse for postfix: i++ --> i -// // note: "b = b++" is equivalent to doing nothing, not to "b++" -// return getDirectBinding(((PostfixExpression) someExpression).lhs); - return null; -} - FieldBinding getLastField(Expression someExpression) { if (someExpression instanceof SingleNameReference) { if ((someExpression.bits & RestrictiveFlagMASK) == Binding.FIELD) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v retrieving revision 1.69 diff -u -r1.69 EqualExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 19 Jul 2007 14:04:59 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 4 Jun 2008 17:22:14 -0000 @@ -808,6 +808,12 @@ CastExpression.checkNeedForArgumentCasts(scope, EQUAL_EQUAL, operatorSignature, left, leftType.id, leftIsCast, right, rightType.id, rightIsCast); } computeConstant(leftType, rightType); + + // check whether comparing identical expressions + Binding leftDirect = Expression.getDirectBinding(left); + if (leftDirect != null && leftDirect == Expression.getDirectBinding(right)) { + scope.problemReporter().comparingIdenticalExpressions(this); + } return this.resolvedType = TypeBinding.BOOLEAN; } @@ -839,6 +845,11 @@ if (unnecessaryRightCast) scope.problemReporter().unnecessaryCast((CastExpression)right); } } + // check whether comparing identical expressions + Binding leftDirect = Expression.getDirectBinding(left); + if (leftDirect != null && leftDirect == Expression.getDirectBinding(right)) { + scope.problemReporter().comparingIdenticalExpressions(this); + } return this.resolvedType = TypeBinding.BOOLEAN; } constant = Constant.NotAConstant; Index: compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java,v retrieving revision 1.38 diff -u -r1.38 AND_AND_Expression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java 10 May 2007 16:05:23 -0000 1.38 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java 4 Jun 2008 17:22:13 -0000 @@ -256,6 +256,19 @@ return false; } + /** + * @see org.eclipse.jdt.internal.compiler.ast.BinaryExpression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope) + */ + public TypeBinding resolveType(BlockScope scope) { + TypeBinding result = super.resolveType(scope); + // check whether comparing identical expressions + Binding leftDirect = Expression.getDirectBinding(left); + if (leftDirect != null && leftDirect == Expression.getDirectBinding(right)) { + scope.problemReporter().comparingIdenticalExpressions(this); + } + return result; + } + public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { left.traverse(visitor, scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v retrieving revision 1.64 diff -u -r1.64 LocalDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 27 May 2008 22:21:13 -0000 1.64 +++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 4 Jun 2008 17:22:14 -0000 @@ -217,7 +217,7 @@ } } // check for assignment with no effect - if (this.binding == Assignment.getDirectBinding(this.initialization)) { + if (this.binding == Expression.getDirectBinding(this.initialization)) { scope.problemReporter().assignmentHasNoEffect(this, this.name); } // change the constant in the binding when it is final Index: compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java,v retrieving revision 1.37 diff -u -r1.37 OR_OR_Expression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 10 May 2007 16:05:23 -0000 1.37 +++ compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 4 Jun 2008 17:22:14 -0000 @@ -255,6 +255,19 @@ return false; } + /** + * @see org.eclipse.jdt.internal.compiler.ast.BinaryExpression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope) + */ + public TypeBinding resolveType(BlockScope scope) { + TypeBinding result = super.resolveType(scope); + // check whether comparing identical expressions + Binding leftDirect = Expression.getDirectBinding(left); + if (leftDirect != null && leftDirect == Expression.getDirectBinding(right)) { + scope.problemReporter().comparingIdenticalExpressions(this); + } + return result; + } + public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { left.traverse(visitor, scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java,v retrieving revision 1.88 diff -u -r1.88 FieldDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 27 May 2008 22:21:13 -0000 1.88 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 4 Jun 2008 17:22:14 -0000 @@ -253,7 +253,7 @@ this.binding.setConstant(Constant.NotAConstant); } // check for assignment with no effect - if (this.binding == Assignment.getDirectBinding(this.initialization)) { + if (this.binding == Expression.getDirectBinding(this.initialization)) { initializationScope.problemReporter().assignmentHasNoEffect(this, this.name); } } 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.370 diff -u -r1.370 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 27 May 2008 22:21:14 -0000 1.370 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 4 Jun 2008 17:22:16 -0000 @@ -315,6 +315,9 @@ case IProblem.RedundantSuperinterface: return CompilerOptions.RedundantSuperinterface; + + case IProblem.ComparingIdentical: + return CompilerOptions.ComparingIdentical; } return 0; } @@ -406,6 +409,7 @@ case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32): case (int)(CompilerOptions.FallthroughCase >>> 32): case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32): + case (int)(CompilerOptions.ComparingIdentical >>> 32): return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; case (int)(CompilerOptions.TypeHiding >>> 32): @@ -743,6 +747,7 @@ location.sourceStart, location.sourceEnd); } + public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) { this.handle( IProblem.VoidMethodReturnsValue, @@ -751,6 +756,8 @@ returnStatement.sourceStart, returnStatement.sourceEnd); } + + public void attemptToReturnVoidValue(ReturnStatement returnStatement) { this.handle( IProblem.MethodReturnsVoid, @@ -1043,6 +1050,17 @@ start, end); } +public void comparingIdenticalExpressions(Expression comparison){ + int severity = computeSeverity(IProblem.ComparingIdentical); + if (severity == ProblemSeverities.Ignore) return; + this.handle( + IProblem.ComparingIdentical, + NoArgument, + NoArgument, + severity, + comparison.sourceStart, + comparison.sourceEnd); +} /* * Given the current configuration, answers which category the problem * falls into: 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.233 diff -u -r1.233 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 21 Apr 2008 10:45:21 -0000 1.233 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 4 Jun 2008 17:22:16 -0000 @@ -160,10 +160,10 @@ 187 = Unreachable catch block for {0}. It is already handled by the catch block for {1} 188 = Empty control-flow statement 189 = Statement unnecessarily nested within else clause. The corresponding then clause does not complete normally -190 = Read access to enclosing field {0}.{1} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance -191 = Write access to enclosing field {0}.{1} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance -192 = Access to enclosing method {1}({2}) from the type {0} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance -193 = Access to enclosing constructor {0}({1}) is emulated by a synthetic accessor method. Increasing its visibility will improve your performance +190 = Read access to enclosing field {0}.{1} is emulated by a synthetic accessor method +191 = Write access to enclosing field {0}.{1} is emulated by a synthetic accessor method +192 = Access to enclosing method {1}({2}) from the type {0} is emulated by a synthetic accessor method +193 = Access to enclosing constructor {0}({1}) is emulated by a synthetic accessor method 194 = Switch case may be entered by falling through previous case 195 = The method {1} is defined in an inherited type and an enclosing scope 196 = The field {0} is defined in an inherited type and an enclosing scope @@ -181,6 +181,7 @@ 208 = Array constants can only be used in initializers 209 = Syntax error on keyword "{0}"; {1} expected 210 = Syntax error on keyword "{0}", no accurate correction available +211 = Comparing identical expressions 220 = Unmatched bracket 221 = The primitive type {0} of {1} does not have a field {2} Index: model/org/eclipse/jdt/core/JavaCore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v retrieving revision 1.615 diff -u -r1.615 JavaCore.java --- model/org/eclipse/jdt/core/JavaCore.java 2 Jun 2008 09:17:38 -0000 1.615 +++ model/org/eclipse/jdt/core/JavaCore.java 4 Jun 2008 17:22:17 -0000 @@ -1456,6 +1456,20 @@ */ public static final String COMPILER_PB_REDUNDANT_SUPERINTERFACE = PLUGIN_ID + ".compiler.problem.redundantSuperinterface"; //$NON-NLS-1$ /** + * Compiler option ID: Reporting Comparison of Identical Expressions. + *
When enabled, the compiler will issue an error or a warning if a comparison
+ * is involving identical operands (e.g 'x == x'
).
+ *
"org.eclipse.jdt.core.compiler.problem.comparingIdentical"
{ "error", "warning", "ignore" }
"warning"
Indicate whether JavaCore should enforce the project build order to be based on
* the classpath prerequisite chain. When requesting to compute, this takes over
Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v
retrieving revision 1.744
diff -u -r1.744 messages.properties
--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 2 Jun 2008 09:17:38 -0000 1.744
+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 4 Jun 2008 17:22:13 -0000
@@ -237,6 +237,7 @@
\ assertIdentifier + ''assert'' used as identifier\n\
\ boxing autoboxing conversion\n\
\ charConcat + char[] in String concat\n\
+\ compareIdentical + comparing identical expressions\n\
\ conditionAssign possible accidental boolean assignment\n\
\ constructorName + method with constructor name\n\
\ dep-ann missing @Deprecated annotation\n\
Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v
retrieving revision 1.327
diff -u -r1.327 Main.java
--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 21 Apr 2008 15:00:59 -0000 1.327
+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 4 Jun 2008 17:22:13 -0000
@@ -3164,6 +3164,10 @@
this.options.put(
CompilerOptions.OPTION_ReportNoEffectAssignment,
isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
+ } else if (token.equals("compareIdentical")) { //$NON-NLS-1$
+ this.options.put(
+ CompilerOptions.OPTION_ReportComparingIdentical,
+ isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
} else if (token.equals("intfNonInherited") || token.equals("interfaceNonInherited")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
this.options.put(
CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v
retrieving revision 1.203
diff -u -r1.203 CompilerOptions.java
--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 14 Apr 2008 19:41:33 -0000 1.203
+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 4 Jun 2008 17:22:15 -0000
@@ -119,7 +119,8 @@
public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
public static final String OPTION_ReportRedundantSuperinterface = "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
-
+ public static final String OPTION_ReportComparingIdentical = "org.eclipse.jdt.core.compiler.problem.comparingIdentical"; //$NON-NLS-1$
+
// Backward compatibility
public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
public static final String OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; //$NON-NLS-1$
@@ -213,6 +214,7 @@
public static final long UnusedTypeArguments = ASTNode.Bit54L;
public static final long UnusedWarningToken = ASTNode.Bit55L;
public static final long RedundantSuperinterface = ASTNode.Bit56L;
+ public static final long ComparingIdentical = ASTNode.Bit57L;
// Map: String optionKey --> Long irritant>
private static Map OptionToIrritants;
@@ -248,7 +250,8 @@
| UnusedLabel
| UnusedTypeArguments
| NullReference
- | UnusedWarningToken;
+ | UnusedWarningToken
+ | ComparingIdentical;
// By default only lines and source attributes are generated.
public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
@@ -459,6 +462,7 @@
optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED);
optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
+ optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
return optionsMap;
}
@@ -589,6 +593,8 @@
return OPTION_ReportUnusedWarningToken;
case (int)(RedundantSuperinterface >>> 32) :
return OPTION_ReportRedundantSuperinterface;
+ case (int)(ComparingIdentical >>> 32) :
+ return OPTION_ReportComparingIdentical;
}
}
return null;
@@ -877,7 +883,8 @@
if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
-
+ if ((optionValue = optionsMap.get(OPTION_ReportComparingIdentical)) != null) updateSeverity(ComparingIdentical, optionValue);
+
// Javadoc options
if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
if (ENABLED.equals(optionValue)) {
@@ -1073,6 +1080,7 @@
buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
+ buf.append("\n\t- comparing identical expr: ").append(getSeverityString(ComparingIdentical)); //$NON-NLS-1$
return buf.toString();
}
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.199
diff -u -r1.199 IProblem.java
--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 27 May 2008 22:21:14 -0000 1.199
+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 4 Jun 2008 17:22:13 -0000
@@ -522,6 +522,9 @@
int ParsingErrorOnKeyword = Syntax + Internal + 209;
int ParsingErrorOnKeywordNoSuggestion = Syntax + Internal + 210;
+ /** @since 3.5 */
+ int ComparingIdentical = Internal + 211;
+
int UnmatchedBracket = Syntax + Internal + 220;
int NoFieldOnBaseType = FieldRelated + 221;
int InvalidExpressionAsStatement = Syntax + Internal + 222;
Index: buidnotes_35.html
===================================================================
RCS file: buidnotes_35.html
diff -N buidnotes_35.html
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ buidnotes_35.html 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,4 @@
+new compiler warning for comparing identical expressions
+https://bugs.eclipse.org/bugs/show_bug.cgi?id=115814
+
+https://bugs.eclipse.org/bugs/show_bug.cgi?id=235004
#P org.eclipse.jdt.core.tests.compiler
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.13
diff -u -r1.13 ProgrammingProblemsTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 27 May 2008 23:54:00 -0000 1.13
+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 4 Jun 2008 17:22:30 -0000
@@ -1339,4 +1339,64 @@
null /* clientRequestor */,
true /* skipJavac */);
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=115814
+public void test0037() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " boolean b1 = args == args;\n" +
+ " boolean b2 = args != args;\n" +
+ " boolean b3 = b1 == b1;\n" +
+ " boolean b4 = b1 != b1;\n" +
+ " boolean b5 = b1 && b1;\n" +
+ " boolean b6 = b1 || b1;\n" +
+ " \n" +
+ " boolean b7 = foo() == foo();\n" +
+ " boolean b8 = foo() != foo();\n" +
+ " boolean b9 = foo() && foo();\n" +
+ " boolean b10 = foo() || foo();\n" +
+ " }\n" +
+ " static boolean foo() { return true; }\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " boolean b1 = args == args;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " boolean b2 = args != args;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 5)\n" +
+ " boolean b3 = b1 == b1;\n" +
+ " ^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 6)\n" +
+ " boolean b4 = b1 != b1;\n" +
+ " ^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 7)\n" +
+ " boolean b5 = b1 && b1;\n" +
+ " ^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "6. WARNING in X.java (at line 8)\n" +
+ " boolean b6 = b1 || b1;\n" +
+ " ^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 16)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
}
\ No newline at end of file
Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v
retrieving revision 1.722
diff -u -r1.722 GenericTypeTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 30 May 2008 13:41:11 -0000 1.722
+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 4 Jun 2008 17:22:29 -0000
@@ -8945,7 +8945,7 @@
"1. WARNING in X.java (at line 6)\n" +
" public int foo(T t) { return t.i + t.i() + T.M.j; }\n" +
" ^^^^^\n" +
- "Read access to enclosing field X