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 199483 Details for
Bug 340747
[1.7][compiler] compiler option to warn when diamond can be used, but type args are used instead.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed fix v1.1 + regression tests
patch340747.txt (text/plain), 39.26 KB, created by
Ayushman Jain
on 2011-07-12 07:10:31 EDT
(
hide
)
Description:
proposed fix v1.1 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-07-12 07:10:31 EDT
Size:
39.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.360.2.3 >diff -u -r1.360.2.3 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 21 Apr 2011 19:10:51 -0000 1.360.2.3 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 12 Jul 2011 11:08:33 -0000 >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Tom Tromey - Contribution for bug 125961 >@@ -3552,9 +3556,11 @@ > setSeverity(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, severity, isEnabling); > setSeverity(CompilerOptions.OPTION_ReportUnusedLabel, severity, isEnabling); > setSeverity(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation, severity, isEnabling); >+ setSeverity(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, severity, isEnabling); > return; > } else if (token.equals("unusedTypeArgs")) { //$NON-NLS-1$ > setSeverity(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation, severity, isEnabling); >+ setSeverity(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, severity, isEnabling); > return; > } else if (token.equals("unavoidableGenericProblems")) { //$NON-NLS-1$ > this.options.put( >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.225.2.23 >diff -u -r1.225.2.23 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 6 Jul 2011 18:46:34 -0000 1.225.2.23 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 12 Jul 2011 11:08:33 -0000 >@@ -1394,6 +1394,8 @@ > int UnhandledExceptionOnAutoClose = TypeRelated + 882; > /** @since 3.7 */ > int DiamondNotBelow17 = TypeRelated + 883; >+ /** @since 3.7 */ >+ int RedundantSpecificationOfTypeArguments = TypeRelated + 884; > /** > * External problems -- These are problems defined by other plugins > */ >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v >retrieving revision 1.84.2.12 >diff -u -r1.84.2.12 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 7 Jul 2011 17:47:46 -0000 1.84.2.12 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 12 Jul 2011 11:08:33 -0000 >@@ -17,12 +17,15 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >+import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.*; > import org.eclipse.jdt.internal.compiler.flow.*; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.*; >+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; >+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > > public class AllocationExpression extends Expression implements InvocationSite { > >@@ -403,6 +406,9 @@ > if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { > scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); > } >+ if (!isDiamond && this.resolvedType.isParameterizedTypeWithActualArguments()) { >+ checkTypeArgumentRedundancy((ParameterizedTypeBinding) this.resolvedType, null, argumentTypes, scope); >+ } > return allocationType; > } > >@@ -421,6 +427,38 @@ > return null; > } > >+public void checkTypeArgumentRedundancy(ParameterizedTypeBinding allocationType, ReferenceBinding enclosingType, TypeBinding[] argumentTypes, final BlockScope scope) { >+ ProblemReporter reporter = scope.problemReporter(); >+ if ((reporter.computeSeverity(IProblem.RedundantSpecificationOfTypeArguments) == ProblemSeverities.Ignore) || scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_7) return; >+ if (allocationType.arguments == null) return; // raw binding >+ if (this.genericTypeArguments != null) return; // diamond can't occur with explicit type args for constructor >+ if (argumentTypes == Binding.NO_PARAMETERS && this.typeExpected instanceof ParameterizedTypeBinding) { >+ ParameterizedTypeBinding expected = (ParameterizedTypeBinding) this.typeExpected; >+ if (expected.arguments != null && allocationType.arguments.length == expected.arguments.length) { >+ // check the case when no ctor takes no params and inference uses the expected type directly >+ // eg. X<String> x = new X<String>() >+ int i; >+ for (i = 0; i < allocationType.arguments.length; i++) { >+ if (allocationType.arguments[i] != expected.arguments[i]) >+ break; >+ } >+ if (i == allocationType.arguments.length) { >+ reporter.redundantDeclarationOfTypeArguments(this.type, allocationType.arguments); >+ return; >+ } >+ } >+ } >+ TypeBinding [] inferredTypes = inferElidedTypes(allocationType.genericType(), enclosingType, argumentTypes, scope); >+ if (inferredTypes == null) { >+ return; >+ } >+ for (int i = 0; i < inferredTypes.length; i++) { >+ if (inferredTypes[i] != allocationType.arguments[i]) >+ return; >+ } >+ reporter.redundantDeclarationOfTypeArguments(this.type, allocationType.arguments); >+} >+ > public void setActualReceiverType(ReferenceBinding receiverType) { > // ignored > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v >retrieving revision 1.101.2.11 >diff -u -r1.101.2.11 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 23 May 2011 10:57:30 -0000 1.101.2.11 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 12 Jul 2011 11:08:33 -0000 >@@ -431,6 +431,9 @@ > if ((this.binding.tagBits & TagBits.HasMissingType) != 0) { > scope.problemReporter().missingTypeInConstructor(this, this.binding); > } >+ if (!isDiamond && receiverType.isParameterizedTypeWithActualArguments()) { >+ checkTypeArgumentRedundancy((ParameterizedTypeBinding)receiverType, receiverType.enclosingType(), argumentTypes , scope); >+ } > // The enclosing instance must be compatible with the innermost enclosing type > ReferenceBinding expectedType = this.binding.declaringClass.enclosingType(); > if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError() >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.241.2.3 >diff -u -r1.241.2.3 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 14 Feb 2011 14:08:01 -0000 1.241.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 12 Jul 2011 11:08:34 -0000 >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 >@@ -136,6 +140,7 @@ > public static final String OPTION_IncludeNullInfoFromAsserts = "org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts"; //$NON-NLS-1$ > public static final String OPTION_ReportMethodCanBeStatic = "org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic"; //$NON-NLS-1$ > public static final String OPTION_ReportMethodCanBePotentiallyStatic = "org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic"; //$NON-NLS-1$ >+ public static final String OPTION_ReportRedundantSpecificationOfTypeArguments = "org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments"; //$NON-NLS-1$ > /** > * Possible values for configurable options > */ >@@ -238,6 +243,7 @@ > public static final int UnusedObjectAllocation = IrritantSet.GROUP2 | ASTNode.Bit4; > public static final int MethodCanBeStatic = IrritantSet.GROUP2 | ASTNode.Bit5; > public static final int MethodCanBePotentiallyStatic = IrritantSet.GROUP2 | ASTNode.Bit6; >+ public static final int RedundantSpecificationOfTypeArguments = IrritantSet.GROUP2 | ASTNode.Bit7; > > // Severity level for handlers > /** >@@ -547,6 +553,8 @@ > return OPTION_ReportMethodCanBeStatic; > case MethodCanBePotentiallyStatic : > return OPTION_ReportMethodCanBePotentiallyStatic; >+ case RedundantSpecificationOfTypeArguments : >+ return OPTION_ReportRedundantSpecificationOfTypeArguments; > } > return null; > } >@@ -682,6 +690,7 @@ > OPTION_ReportRawTypeReference, > OPTION_ReportRedundantNullCheck, > OPTION_ReportRedundantSuperinterface, >+ OPTION_ReportRedundantSpecificationOfTypeArguments, > OPTION_ReportSpecialParameterHidingField, > OPTION_ReportSyntheticAccessEmulation, > OPTION_ReportTasks, >@@ -763,6 +772,7 @@ > case UnusedDeclaredThrownException : > case DeadCode : > case UnusedObjectAllocation : >+ case RedundantSpecificationOfTypeArguments : > return "unused"; //$NON-NLS-1$ > case DiscouragedReference : > case ForbiddenReference : >@@ -973,6 +983,7 @@ > optionsMap.put(OPTION_IncludeNullInfoFromAsserts, this.includeNullInfoFromAsserts ? ENABLED : DISABLED); > optionsMap.put(OPTION_ReportMethodCanBeStatic, getSeverityString(MethodCanBeStatic)); > optionsMap.put(OPTION_ReportMethodCanBePotentiallyStatic, getSeverityString(MethodCanBePotentiallyStatic)); >+ optionsMap.put(OPTION_ReportRedundantSpecificationOfTypeArguments, getSeverityString(RedundantSpecificationOfTypeArguments)); > return optionsMap; > } > >@@ -1402,6 +1413,7 @@ > if ((optionValue = optionsMap.get(OPTION_ReportUnusedObjectAllocation)) != null) updateSeverity(UnusedObjectAllocation, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportMethodCanBeStatic)) != null) updateSeverity(MethodCanBeStatic, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportMethodCanBePotentiallyStatic)) != null) updateSeverity(MethodCanBePotentiallyStatic, optionValue); >+ if ((optionValue = optionsMap.get(OPTION_ReportRedundantSpecificationOfTypeArguments)) != null) updateSeverity(RedundantSpecificationOfTypeArguments, optionValue); > > // Javadoc options > if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) { >@@ -1616,6 +1628,7 @@ > buf.append("\n\t- unused object allocation: ").append(getSeverityString(UnusedObjectAllocation)); //$NON-NLS-1$ > buf.append("\n\t- method can be static: ").append(getSeverityString(MethodCanBeStatic)); //$NON-NLS-1$ > buf.append("\n\t- method can be potentially static: ").append(getSeverityString(MethodCanBePotentiallyStatic)); //$NON-NLS-1$ >+ buf.append("\n\t- redundant specification of type arguments: ").append(getSeverityString(RedundantSpecificationOfTypeArguments)); //$NON-NLS-1$ > return buf.toString(); > } > >Index: compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java,v >retrieving revision 1.13.2.1 >diff -u -r1.13.2.1 IrritantSet.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java 11 Feb 2011 15:17:16 -0000 1.13.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java 12 Jul 2011 11:08:34 -0000 >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ >@@ -120,7 +124,8 @@ > .set(CompilerOptions.UnusedTypeArguments) > .set(CompilerOptions.RedundantSuperinterface) > .set(CompilerOptions.DeadCode) >- .set(CompilerOptions.UnusedObjectAllocation); >+ .set(CompilerOptions.UnusedObjectAllocation) >+ .set(CompilerOptions.RedundantSpecificationOfTypeArguments); > STATIC_METHOD > .set(CompilerOptions.MethodCanBePotentiallyStatic); > String suppressRawWhenUnchecked = System.getProperty("suppressRawWhenUnchecked"); //$NON-NLS-1$ >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.430.2.34 >diff -u -r1.430.2.34 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 6 Jul 2011 18:46:35 -0000 1.430.2.34 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 12 Jul 2011 11:08:35 -0000 >@@ -430,6 +430,9 @@ > > case IProblem.MethodCanBePotentiallyStatic: > return CompilerOptions.MethodCanBePotentiallyStatic; >+ >+ case IProblem.RedundantSpecificationOfTypeArguments: >+ return CompilerOptions.RedundantSpecificationOfTypeArguments; > } > return 0; > } >@@ -502,7 +505,8 @@ > case CompilerOptions.UnhandledWarningToken : > case CompilerOptions.UnusedWarningToken : > case CompilerOptions.UnusedLabel : >- case CompilerOptions.RedundantSuperinterface : >+ case CompilerOptions.RedundantSuperinterface : >+ case CompilerOptions.RedundantSpecificationOfTypeArguments : > return CategorizedProblem.CAT_UNNECESSARY_CODE; > > case CompilerOptions.UsingDeprecatedAPI : >@@ -7884,4 +7888,20 @@ > type.sourceStart, > type.sourceEnd); > } >+public void redundantDeclarationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes) { >+ int severity = computeSeverity(IProblem.RedundantSpecificationOfTypeArguments); >+ int sourceStart = -1; >+ if (location instanceof QualifiedTypeReference) { >+ sourceStart = (int) (((QualifiedTypeReference)location).sourcePositions[((QualifiedTypeReference)location).sourcePositions.length - 1] >> 32); >+ } >+ if (severity != ProblemSeverities.Ignore) { >+ this.handle( >+ IProblem.RedundantSpecificationOfTypeArguments, >+ new String[] {typesAsString(argumentTypes, false)}, >+ new String[] {typesAsString(argumentTypes, true)}, >+ severity, >+ sourceStart == -1? location.sourceStart : sourceStart, >+ location.sourceEnd); >+ } >+} > } >\ No newline at end of file >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.262.2.31 >diff -u -r1.262.2.31 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 6 Jul 2011 18:46:35 -0000 1.262.2.31 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 12 Jul 2011 11:08:35 -0000 >@@ -646,6 +646,7 @@ > 881 = Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted > 882 = Unhandled exception type {0} thrown by automatic close() invocation on {1} > 883 = '<>' operator is not allowed for source level below 1.7 >+884 = Redundant specification of type arguments <{0}> > > ### ELABORATIONS > ## Access restrictions >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.659.2.2 >diff -u -r1.659.2.2 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 19 Apr 2011 16:41:17 -0000 1.659.2.2 >+++ model/org/eclipse/jdt/core/JavaCore.java 12 Jul 2011 11:08:37 -0000 >@@ -1658,6 +1658,20 @@ > */ > public static final String COMPILER_PB_UNUSED_OBJECT_ALLOCATION = PLUGIN_ID + ".compiler.problem.unusedObjectAllocation"; //$NON-NLS-1$ > /** >+ * Compiler option ID: Reporting redundant specification of type arguments in class instance creation expressions. >+ * <p>When enabled, the compiler will issue an error or a warning if type arguments are used in a class instance creation, >+ * when the '<>' operator can be used instead. >+ * <p>This option only has an effect if the compiler compliance is 1.7 or greater.</p> >+ * <dl> >+ * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.redundantDeclarationOfTypeArguments"</code></dd> >+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd> >+ * <dt>Default:</dt><dd><code>"ignore"</code></dd> >+ * </dl> >+ * @since 3.7 >+ * @category CompilerOptionID >+ */ >+ public static final String COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS = PLUGIN_ID + ".compiler.problem.redundantSpecificationOfTypeArguments"; //$NON-NLS-1$ >+ /** > * Core option ID: Computing Project Build Order. > * <p>Indicate whether JavaCore should enforce the project build order to be based on > * the classpath prerequisite chain. When requesting to compute, this takes over >#P org.eclipse.jdt.core.tests.compiler >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.224.2.2 >diff -u -r1.224.2.2 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 28 Jun 2011 19:34:33 -0000 1.224.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 12 Jul 2011 11:08:41 -0000 >@@ -5,6 +5,10 @@ > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * >+ * This is an implementation of an early-draft specification developed under the Java >+ * Community Process (JCP) and is made available for testing and evaluation purposes >+ * only. The code is not compatible with any specification of the JCP. >+ * > * Contributors: > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 >@@ -1857,7 +1861,8 @@ > " <option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" + >- " <option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" + >+ " <option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" + >+ " <option key=\"org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic\" value=\"ignore\"/>\n" + >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.40.2.19 >diff -u -r1.40.2.19 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 6 Jul 2011 18:45:55 -0000 1.40.2.19 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 12 Jul 2011 11:08:42 -0000 >@@ -775,6 +775,7 @@ > expectedProblemAttributes.put("RecursiveConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("RedefinedArgument", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("RedefinedLocal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >+ expectedProblemAttributes.put("RedundantSpecificationOfTypeArguments", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE)); > expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("RedundantNullCheckOnNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); >@@ -1441,6 +1442,7 @@ > expectedProblemAttributes.put("RecursiveConstructorInvocation", SKIP); > expectedProblemAttributes.put("RedefinedArgument", SKIP); > expectedProblemAttributes.put("RedefinedLocal", SKIP); >+ expectedProblemAttributes.put("RedundantSpecificationOfTypeArguments", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS)); > expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK)); > expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK)); > expectedProblemAttributes.put("RedundantNullCheckOnNullLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK)); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Attic/GenericsRegressionTest_1_7.java,v >retrieving revision 1.1.2.22 >diff -u -r1.1.2.22 GenericsRegressionTest_1_7.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java 5 Jul 2011 11:02:30 -0000 1.1.2.22 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java 12 Jul 2011 11:08:42 -0000 >@@ -14,6 +14,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >+import java.util.Map; >+ >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+ > import junit.framework.Test; > public class GenericsRegressionTest_1_7 extends AbstractRegressionTest { > >@@ -1811,6 +1815,409 @@ > }, > ""); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0052() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<E> {\n" + >+ " X(E e) {}\n" + >+ " X() {}\n" + >+ " public static void main(String[] args) {\n" + >+ " X<Number> x = new X<Number>(1);\n" + >+ " X<String> x2 = new X<String>(\"SUCCESS\");\n" + >+ " X<Integer> x3 = new X<Integer>(1);\n" + >+ " X<AX> x4 = new X<AX>(new AX());\n" + >+ " X<? extends AX> x5 = new X<AX<String>>(new AX<String>());\n" + >+ " X<?> x6 = new X<AX<String>>(new AX<String>());\n" + >+ " X<Class<? extends Object>> x7 = new X<Class<? extends Object>>();\n" + >+ " }\n" + >+ "}\n" + >+ "class AX<T>{}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " X<String> x2 = new X<String>(\"SUCCESS\");\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <String>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " X<Integer> x3 = new X<Integer>(1);\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " X<AX> x4 = new X<AX>(new AX());\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <AX>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 9)\n" + >+ " X<? extends AX> x5 = new X<AX<String>>(new AX<String>());\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <AX<String>>\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 10)\n" + >+ " X<?> x6 = new X<AX<String>>(new AX<String>());\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <AX<String>>\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 11)\n" + >+ " X<Class<? extends Object>> x7 = new X<Class<? extends Object>>();\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <Class<? extends Object>>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0052b() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<E> {\n" + >+ " E eField;\n" + >+ " E get() { return this.eField; }\n" + >+ " X(E e) {}\n" + >+ " X(int e, String e2) {}\n" + >+ " public static void main(String[] args) {\n" + >+ " X<Number> x = new X<Number>(1);\n" + >+ " X<String> x2 = new X<String>(\"SUCCESS\");\n" + >+ " X<String> x22 = new X<String>(1,\"SUCCESS\");\n" + >+ " X<Integer> x3 = new X<Integer>(1);\n" + >+ " String s = foo(new X<String>(\"aaa\"));\n" + >+ " String s2 = foo(new X<String>(1,\"aaa\"));\n" + >+ " }\n" + >+ " static String foo(X<String> x) {\n" + >+ " return x.get();\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 8)\n" + >+ " X<String> x2 = new X<String>(\"SUCCESS\");\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <String>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " X<String> x22 = new X<String>(1,\"SUCCESS\");\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <String>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 10)\n" + >+ " X<Integer> x3 = new X<Integer>(1);\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 11)\n" + >+ " String s = foo(new X<String>(\"aaa\"));\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <String>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0052c() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<E> {\n" + >+ " X(String abc, String def) {}\n" + >+ " void foo() {\n" + >+ " X<Integer> x = new X<Integer>(\"\",\"\");\n" + >+ " foo3(new X<Integer>(\"\",\"\"));\n" + >+ " }\n" + >+ " X<Integer> foo2() {\n" + >+ " return new X<Integer>(\"\",\"\");\n" + >+ " }\n" + >+ " void foo3(X<Integer> x) {}\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " X<Integer> x = new X<Integer>(\"\",\"\");\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " return new X<Integer>(\"\",\"\");\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0053() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "Z.java", >+ "public class Z <T extends ZB> { \n" + >+ " public static void main(String[] args) {\n" + >+ " foo(new Z<ZB>());\n" + >+ " }\n" + >+ " static void foo(Z<ZB> z) {\n" + >+ " }\n" + >+ "}\n" + >+ "class ZB {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in Z.java (at line 3)\n" + >+ " foo(new Z<ZB>());\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <ZB>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0054() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "Y.java", >+ "public class Y<V> {\n" + >+ " public static <W extends ABC> Y<W> make(Class<W> clazz) {\n" + >+ " return new Y<W>();\n" + >+ " }\n" + >+ "}\n" + >+ "class ABC{}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in Y.java (at line 3)\n" + >+ " return new Y<W>();\n" + >+ " ^\n" + >+ "Redundant specification of type arguments <W>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0055() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<A> {\n" + >+ " class Inner<B> { }\n" + >+ " static class Inner2<C> { }\n" + >+ "\n" + >+ " void method() {\n" + >+ " X<String>.Inner<Integer> a= new X<String>().new Inner<Integer>();\n" + >+ " Inner<Integer> b= new X<A>().new Inner<Integer>();\n" + >+ " Inner<Integer> c= new Inner<Integer>();\n" + >+ " X<A>.Inner<Integer> e= new X<A>().new Inner<Integer>();\n" + >+ " X<A>.Inner<Integer> f= new Inner<Integer>();\n" + >+ " X.Inner2<Integer> d3 = new X.Inner2<Integer>();\n" + >+ " }\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " X<String>.Inner<Integer> a= new X<String>().new Inner<Integer>();\n" + >+ " ^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " Inner<Integer> b= new X<A>().new Inner<Integer>();\n" + >+ " ^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " Inner<Integer> c= new Inner<Integer>();\n" + >+ " ^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 9)\n" + >+ " X<A>.Inner<Integer> e= new X<A>().new Inner<Integer>();\n" + >+ " ^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 10)\n" + >+ " X<A>.Inner<Integer> f= new Inner<Integer>();\n" + >+ " ^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 11)\n" + >+ " X.Inner2<Integer> d3 = new X.Inner2<Integer>();\n" + >+ " ^^^^^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+// qualified allocation >+public void test0056() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X <T> {\n" + >+ " void foo1() {\n" + >+ " X<String>.Item<Thread> i = new X<Exception>().new Item<Thread>();\n" + >+ " }\n" + >+ " void foo2() {\n" + >+ " X<Exception>.Item<Thread> j = new X<Exception>.Item<Thread>();\n" + >+ " }\n" + >+ " class Item <E> {}\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " X<String>.Item<Thread> i = new X<Exception>().new Item<Thread>();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X<Exception>.Item<Thread> to X<String>.Item<Thread>\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " X<String>.Item<Thread> i = new X<Exception>().new Item<Thread>();\n" + >+ " ^^^^\n" + >+ "Redundant specification of type arguments <Thread>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 6)\n" + >+ " X<Exception>.Item<Thread> j = new X<Exception>.Item<Thread>();\n" + >+ " ^^^^^^^^^^^^^^^^^\n" + >+ "Cannot allocate the member type X<Exception>.Item<Thread> using a parameterized compound name; use its simple name and an enclosing instance of type X<Exception>\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 6)\n" + >+ " X<Exception>.Item<Thread> j = new X<Exception>.Item<Thread>();\n" + >+ " ^^^^\n" + >+ "Redundant specification of type arguments <Thread>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+// qualified allocation >+public void test0056b() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X <T> {\n" + >+ " static class X1<Z> {\n" + >+ " X1(Z z){}\n" + >+ " }\n" + >+ " X1<Integer> x1 = new X.X1<Integer>(1);\n" + >+ " X1<Number> x2 = new X.X1<Number>(1);\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " X1<Integer> x1 = new X.X1<Integer>(1);\n" + >+ " ^^\n" + >+ "Redundant specification of type arguments <Integer>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0057() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void test() {\n" + >+ " Pair<Double, Integer> p = new InvertedPair<Integer, Double>();\n" + >+ " }\n" + >+ "}\n" + >+ "class Pair<A, B> {\n" + >+ "}\n" + >+ "class InvertedPair<A, B> extends Pair<B, A> {\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " Pair<Double, Integer> p = new InvertedPair<Integer, Double>();\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Redundant specification of type arguments <Integer, Double>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0058() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.ArrayList;\n" + >+ "\n" + >+ "public class X {\n" + >+ " public void test(boolean param) {\n" + >+ " ArrayList<?> ls = (param) \n" + >+ " ? new ArrayList<String>()\n" + >+ " : new ArrayList<Object>();\n" + >+ " \n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " : new ArrayList<Object>();\n" + >+ " ^^^^^^^^^\n" + >+ "Redundant specification of type arguments <Object>\n" + >+ "----------\n", >+ null, >+ false, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340747 >+public void test0059() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSpecificationOfTypeArguments, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.util.ArrayList;\n" + >+ "import java.util.List;\n" + >+ "\n" + >+ "public class X<T> {\n" + >+ " X(List<? extends T> p) {}\n" + >+ " Object x = new X<CharSequence>((ArrayList<String>) null);\n" + >+ "}\n" >+ }, >+ "", >+ null, >+ false, >+ customOptions); >+} > public static Class testClass() { > return GenericsRegressionTest_1_7.class; > }
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 340747
:
199376
|
199377
|
199483
|
199547