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 71591 Details for
Bug 77918
[compiler] Unnecessary implementation of interface in class declaration
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]
Suggested implementation + test cases
patch.txt (text/plain), 31.04 KB, created by
Maxime Daniel
on 2007-06-18 05:01:22 EDT
(
hide
)
Description:
Suggested implementation + test cases
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-06-18 05:01:22 EDT
Size:
31.04 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.188 >diff -u -r1.188 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 2 Mar 2007 10:46:03 -0000 1.188 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 18 Jun 2007 08:49:20 -0000 >@@ -108,6 +108,8 @@ > * NullLocalVariableInstanceofYieldsFalse > * RedundantNullCheckOnNonNullLocalVariable > * NonNullLocalVariableComparisonYieldsFalse >+ * IBM Corporation - added the following constants >+ * RedundantSuperInterface > *******************************************************************************/ > package org.eclipse.jdt.core.compiler; > >@@ -611,6 +613,7 @@ > int ObjectCannotHaveSuperTypes = Internal + 329; > /** @since 3.1 */ > int ObjectMustBeClass = Internal + 330; >+ // non-deprecated, non-generic type related problems continue at 660 > > /** @deprecated - problem is no longer generated, use {@link #UndefinedType} instead */ > int SuperclassNotFound = TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330 >@@ -1171,6 +1174,10 @@ > /** @since 3.3 */ > int MethodMustOverrideOrImplement = MethodRelated + 634; > >+ // non-generic type related, cont'd >+ /** @since 3.4 */ >+ int RedundantSuperInterface = TypeRelated + 660; >+ > /** > * Corrupted binaries > */ >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.220 >diff -u -r1.220 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 26 Mar 2007 17:16:24 -0000 1.220 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 18 Jun 2007 08:49:22 -0000 >@@ -542,6 +542,9 @@ > 633 = The value for annotation attribute {0}.{1} must be an enum constant expression > 634 = The method {0}({1}) of type {2} must override or implement a supertype method > >+### TYPES CONT'D >+660 = Redundant interface {0} for the type {1} >+ > ### CORRUPTED BINARIES > 700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2} > >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.348 >diff -u -r1.348 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Apr 2007 17:16:24 -0000 1.348 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 18 Jun 2007 08:49:21 -0000 >@@ -293,6 +293,9 @@ > > case IProblem.OverridingMethodWithoutSuperInvocation: > return CompilerOptions.OverridingMethodWithoutSuperInvocation; >+ >+ case IProblem.RedundantSuperInterface: >+ return CompilerOptions.RedundantInterface; > } > return 0; > } >@@ -391,6 +394,7 @@ > > case (int)(CompilerOptions.UnhandledWarningToken >>> 32): > case (int)(CompilerOptions.UnusedLabel >>> 32): >+ case (int)(CompilerOptions.RedundantInterface >>> 32): > return CategorizedProblem.CAT_UNNECESSARY_CODE; > > case (int)(CompilerOptions.ForbiddenReference >>> 32): >@@ -5529,7 +5533,22 @@ > localDecl.sourceStart, > localDecl.sourceEnd); > } >- >+public void redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) { >+ int severity = computeSeverity(IProblem.RedundantSuperInterface); >+ if (severity != ProblemSeverities.Ignore) { >+ this.handle( >+ IProblem.RedundantSuperInterface, >+ new String[] { >+ new String(superType.readableName()), >+ new String(type.sourceName())}, >+ new String[] { >+ new String(superType.shortReadableName()), >+ new String(type.sourceName())}, >+ severity, >+ reference.sourceStart, >+ reference.sourceEnd); >+ } >+} > public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) { > this.handle( > IProblem.ArrayReferenceRequired, >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.577 >diff -u -r1.577 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 1 Jun 2007 13:52:19 -0000 1.577 >+++ model/org/eclipse/jdt/core/JavaCore.java 18 Jun 2007 08:49:22 -0000 >@@ -68,6 +68,8 @@ > * COMPILER_PB_REDUNDANT_NULL_CHECK > * IBM Corporation - added the following constants: > * COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE >+ * IBM Corporation - added the following constants: >+ * COMPILER_PB_REDUNDANT_INTERFACE > *******************************************************************************/ > package org.eclipse.jdt.core; > >@@ -709,6 +711,12 @@ > /** > * Possible configurable option ID. > * @see #getDefaultOptions() >+ * @since 3.4 >+ */ >+ public static final String COMPILER_PB_REDUNDANT_INTERFACE = PLUGIN_ID + ".compiler.problem.redundantInterface"; //$NON-NLS-1$ >+ /** >+ * Possible configurable option ID. >+ * @see #getDefaultOptions() > */ > public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$ > /** >@@ -2482,6 +2490,14 @@ > * - possible values: { "error", "warning", "ignore" } > * - default: "ignore" > * >+ * COMPILER / Reporting Redundant Super Interface >+ * When enabled, the compiler will issue an error or a warning if a class >+ * explicitly implements an interface that is already implemented by any >+ * of its superclasses. >+ * - option id: "org.eclipse.jdt.core.compiler.problem.redundantInterface" >+ * - possible values: { "error", "warning", "ignore" } >+ * - default: "ignore" >+ * > * BUILDER / Specifying Filters for Resource Copying Control > * Allow to specify some filters to control the resource copy process. > * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter" >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.184 >diff -u -r1.184 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 7 May 2007 17:01:22 -0000 1.184 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 18 Jun 2007 08:49:20 -0000 >@@ -113,6 +113,7 @@ > public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$ > 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.redundantInterface"; //$NON-NLS-1$ > > // Backward compatibility > public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$ >@@ -199,6 +200,7 @@ > public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L; > public static final long PotentialNullReference = ASTNode.Bit51L; > public static final long RedundantNullCheck = ASTNode.Bit52L; >+ public static final long RedundantInterface = ASTNode.Bit53L; > > // Map: String optionKey --> Long irritant> > private static Map OptionToIrritants; >@@ -434,6 +436,7 @@ > optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation)); > optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED); > optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED); >+ optionsMap.put(OPTION_ReportRedundantSuperInterface, getSeverityString(RedundantInterface)); > return optionsMap; > } > >@@ -556,6 +559,8 @@ > return OPTION_ReportFallthroughCase; > case (int)(OverridingMethodWithoutSuperInvocation >>> 32) : > return OPTION_ReportOverridingMethodWithoutSuperInvocation; >+ case (int)(RedundantInterface >>> 32) : >+ return OPTION_ReportRedundantSuperInterface; > } > } > return null; >@@ -823,6 +828,7 @@ > if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue); > if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue); >+ if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperInterface)) != null) updateSeverity(RedundantInterface, optionValue); > > // Javadoc options > if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) { >@@ -1010,6 +1016,7 @@ > buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$ > buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$ > buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$ >+ buf.append("\n\t- redundant interface: ").append(getSeverityString(RedundantInterface)); //$NON-NLS-1$ > return buf.toString(); > } > >@@ -1093,7 +1100,6 @@ > /** > * Return all warning option names for use as keys in compiler options maps. > * @return all warning option names >- * TODO (maxime) revise for ensuring completeness > */ > public static String[] warningOptionNames() { > String[] result = { >@@ -1101,6 +1107,8 @@ > OPTION_ReportAssertIdentifier, > OPTION_ReportAutoboxing, > OPTION_ReportDeprecation, >+ OPTION_ReportDeprecationInDeprecatedCode, >+ OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, > OPTION_ReportDiscouragedReference, > OPTION_ReportEmptyStatement, > OPTION_ReportEnumIdentifier, >@@ -1113,12 +1121,23 @@ > OPTION_ReportIncompatibleNonInheritedInterfaceMethod, > OPTION_ReportIncompleteEnumSwitch, > OPTION_ReportIndirectStaticAccess, >+ OPTION_ReportInvalidAnnotation, > OPTION_ReportInvalidJavadoc, >+ OPTION_ReportInvalidJavadocTags, >+ OPTION_ReportInvalidJavadocTagsDeprecatedRef, >+ OPTION_ReportInvalidJavadocTagsNotVisibleRef, >+ OPTION_ReportInvalidJavadocTagsVisibility, > OPTION_ReportLocalVariableHiding, > OPTION_ReportMethodWithConstructorName, >+ OPTION_ReportMissingAnnotation, > OPTION_ReportMissingDeprecatedAnnotation, >+ OPTION_ReportMissingJavadoc, > OPTION_ReportMissingJavadocComments, >+ OPTION_ReportMissingJavadocCommentsOverriding, >+ OPTION_ReportMissingJavadocCommentsVisibility, > OPTION_ReportMissingJavadocTags, >+ OPTION_ReportMissingJavadocTagsOverriding, >+ OPTION_ReportMissingJavadocTagsVisibility, > OPTION_ReportMissingOverrideAnnotation, > OPTION_ReportMissingSerialVersion, > OPTION_ReportNoEffectAssignment, >@@ -1126,26 +1145,34 @@ > OPTION_ReportNonExternalizedStringLiteral, > OPTION_ReportNonStaticAccessToStatic, > OPTION_ReportNullReference, >- OPTION_ReportPotentialNullReference, >- OPTION_ReportRedundantNullCheck, >+ OPTION_ReportOverridingMethodWithoutSuperInvocation, > OPTION_ReportOverridingPackageDefaultMethod, > OPTION_ReportParameterAssignment, > OPTION_ReportPossibleAccidentalBooleanAssignment, >+ OPTION_ReportPotentialNullReference, >+ OPTION_ReportRawTypeReference, >+ OPTION_ReportRedundantNullCheck, >+ OPTION_ReportRedundantSuperInterface, >+ OPTION_ReportSpecialParameterHidingField, > OPTION_ReportSyntheticAccessEmulation, > OPTION_ReportTypeParameterHiding, > OPTION_ReportUncheckedTypeOperation, > OPTION_ReportUndocumentedEmptyBlock, >+ OPTION_ReportUnhandledWarningToken, > OPTION_ReportUnnecessaryElse, > OPTION_ReportUnnecessaryTypeCheck, > OPTION_ReportUnqualifiedFieldAccess, > OPTION_ReportUnusedDeclaredThrownException, >+ OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding, > OPTION_ReportUnusedImport, >+ OPTION_ReportUnusedLabel, > OPTION_ReportUnusedLocal, > OPTION_ReportUnusedParameter, >+ OPTION_ReportUnusedParameterIncludeDocCommentReference, >+ OPTION_ReportUnusedParameterWhenImplementingAbstract, >+ OPTION_ReportUnusedParameterWhenOverridingConcrete, > OPTION_ReportUnusedPrivateMember, > OPTION_ReportVarargsArgumentNeedCast, >- OPTION_ReportUnhandledWarningToken, >- OPTION_ReportOverridingMethodWithoutSuperInvocation > }; > return result; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.149 >diff -u -r1.149 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 15 May 2007 14:39:22 -0000 1.149 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 18 Jun 2007 08:49:20 -0000 >@@ -23,8 +23,10 @@ > import org.eclipse.jdt.internal.compiler.ast.TypeReference; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.env.AccessRestriction; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; >+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; > > public class ClassScope extends Scope { >@@ -766,6 +768,52 @@ > currentType.tagBits |= TagBits.HasNoMemberTypes; > } while ((currentType = currentType.superclass()) != null && (currentType.tagBits & TagBits.HasNoMemberTypes) == 0); > } >+ >+ private void checkForRedundantInterfaces() { >+ ReferenceBinding[] superInterfaces = >+ this.referenceContext.binding.superInterfaces; >+ if (superInterfaces.length > 0) { >+ // collect redundant interfaces >+ int length = superInterfaces.length; >+ boolean[] superInterfaceIsRedundant = null; >+ for (ReferenceBinding current = this.referenceContext.binding.superclass(); >+ current != null; current = current.superclass()) { >+ ReferenceBinding[] checkedInterfaces = current.superInterfaces(); >+ if (checkedInterfaces == null) { // hierarchy cycle - may get rid of this depending on bug 192620 >+ break; >+ } else if (checkedInterfaces.length == 0) { >+ continue; >+ } >+ nextInterface: for (int i = 0; i < length; i++) { >+ if (superInterfaceIsRedundant == null || >+ ! superInterfaceIsRedundant[i]) { >+ for (int j = checkedInterfaces.length - 1; j >= 0; j--) { >+ if (superInterfaces[i] == checkedInterfaces[j]) { >+ if (superInterfaceIsRedundant == null) { >+ superInterfaceIsRedundant = new boolean[length]; >+ } >+ superInterfaceIsRedundant[i] = true; >+ continue nextInterface; >+ } >+ } >+ } >+ } >+ } >+ // complain if needed >+ if (superInterfaceIsRedundant != null) { >+ for (int i = 0; i < length; i++) { >+ if (superInterfaceIsRedundant[i]) { >+ // skip duplicates on the reference context >+ int j = i; >+ while (this.referenceContext.superInterfaces[j].resolvedType != superInterfaces[i]) { >+ j++; >+ } >+ problemReporter().redundantSuperInterface(this.referenceContext.binding, this.referenceContext.superInterfaces[j], superInterfaces[i]); >+ } >+ } >+ } >+ } >+ } > > // Perform deferred bound checks for parameterized type references (only done after hierarchy is connected) > public void checkParameterizedTypeBounds() { >@@ -948,7 +996,7 @@ > } > > void connectTypeHierarchy() { >- SourceTypeBinding sourceType = referenceContext.binding; >+ SourceTypeBinding sourceType = referenceContext.binding; > if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) == 0) { > sourceType.tagBits |= TagBits.BeginHierarchyCheck; > boolean noProblems = connectSuperclass(); >@@ -956,8 +1004,15 @@ > sourceType.tagBits |= TagBits.EndHierarchyCheck; > noProblems &= connectTypeVariables(referenceContext.typeParameters, false); > sourceType.tagBits |= TagBits.TypeVariablesAreConnected; >- if (noProblems && sourceType.isHierarchyInconsistent()) >- problemReporter().hierarchyHasProblems(sourceType); >+ if (noProblems) { >+ if (sourceType.isHierarchyInconsistent()) { >+ problemReporter().hierarchyHasProblems(sourceType); >+ } else if (!sourceType.isInterface() && >+ compilerOptions().getSeverity(CompilerOptions.RedundantInterface) >+ != ProblemSeverities.Ignore){ >+ checkForRedundantInterfaces(); >+ } >+ } > } > connectMemberTypes(); > LookupEnvironment env = environment(); >#P org.eclipse.jdt.core.tests.model >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java,v >retrieving revision 1.3 >diff -u -r1.3 SuperTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java 28 Jun 2006 14:23:59 -0000 1.3 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java 18 Jun 2007 08:49:39 -0000 >@@ -10,6 +10,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 SuperTypeTest extends AbstractRegressionTest { >@@ -263,4 +267,198 @@ > "----------\n" > ); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// default is silent >+public void test008() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements I, J {\n" + >+ "}" >+ }, >+ "" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// raising an error >+public void test009() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements I, J {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y extends X implements I, J {\n" + >+ " ^\n" + >+ "Redundant interface I for the type Y\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// raising an error - with true duplicates >+public void test010() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements I, J, I {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y extends X implements I, J, I {\n" + >+ " ^\n" + >+ "Redundant interface I for the type Y\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " class Y extends X implements I, J, I {\n" + >+ " ^\n" + >+ "Duplicate interface I for the type Y\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// raising an error - deeper hierarchy >+public void test011() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X {\n" + >+ "}\n" + >+ "class Z extends Y implements J, I {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " class Z extends Y implements J, I {\n" + >+ " ^\n" + >+ "Redundant interface I for the type Z\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// no error - deeper hierarchy >+public void test012() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements J {\n" + >+ "}\n" + >+ "class Z extends Y {\n" + >+ "}" >+ }, >+ "", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ null /* no vm arguments */, >+ customOptions, >+ null /* no custom requestor*/); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// no error - extending interfaces >+// deliberate choice so far: no attempt to detect that since J extends I, >+// implementing I is redundant >+public void test013() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X implements J {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n" + >+ "interface J extends I {\n" + >+ "}\n" + >+ "class Y extends X implements I {\n" + >+ "}\n" >+ }, >+ "", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ null /* no vm arguments */, >+ customOptions, >+ null /* no custom requestor*/); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// error due to cycles (guarding the null case) >+public void test014() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ "}\n" + >+ "interface I {\n" + >+ "}\n", >+ "CycleParent.java", >+ "class CycleParent extends CycleBase<CycleChild> {\n" + >+ "}\n", >+ "CycleBase.java", >+ "class CycleBase<T extends CycleBase> {\n" + >+ "}\n", >+ "CycleChild.java", >+ "class CycleChild extends CycleParent implements Comparable<CycleChild> {\n" + >+ " public int compareTo(CycleChild o) { \n" + >+ " return 0; \n" + >+ " }\n" + >+ "}" >+ }, >+ "ERR", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} > } >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.115 >diff -u -r1.115 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 5 Jun 2007 11:07:52 -0000 1.115 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 18 Jun 2007 08:49:33 -0000 >@@ -1268,6 +1268,7 @@ > " <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.redundantInterface\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + >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.631 >diff -u -r1.631 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 22 May 2007 15:42:35 -0000 1.631 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 18 Jun 2007 08:49:39 -0000 >@@ -38019,4 +38019,156 @@ > "Cycle detected: the type X cannot extend/implement itself or one of its own member types\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// generic variants >+public void test1142() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, >+ CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X implements I {\n" + >+ "}\n" + >+ "interface I <T> {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements I, J {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y extends X implements I, J {\n" + >+ " ^\n" + >+ "Redundant interface I for the type Y\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// generic variants >+public void test1143() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X implements I<Object> {\n" + >+ "}\n" + >+ "interface I <T> {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y extends X implements I<Object>, J {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y extends X implements I<Object>, J {\n" + >+ " ^\n" + >+ "Redundant interface I<Object> for the type Y\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// generic variants >+public void test1144() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> implements I<T> {\n" + >+ "}\n" + >+ "interface I <T> {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y<T extends Z> extends X<T> implements I<T>, J {\n" + >+ "}\n" + >+ "class Z {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y<T extends Z> extends X<T> implements I<T>, J {\n" + >+ " ^\n" + >+ "Redundant interface I<T> for the type Y\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// generic variants - the 'different arguments' error overrides the >+// redundant error >+public void test1145() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> implements I<T> {\n" + >+ "}\n" + >+ "interface I <T> {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + >+ "}\n" + >+ "class Z {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + >+ " ^\n" + >+ "The interface I cannot be implemented more than once with different arguments: I<T> and I<U>\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918 >+// generic variants - the 'different arguments' error overrides the >+// redundant error >+public void test1146() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, >+ CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, >+ CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> implements I {\n" + >+ "}\n" + >+ "interface I <T> {\n" + >+ "}\n" + >+ "interface J {\n" + >+ "}\n" + >+ "class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + >+ "}\n" + >+ "class Z {\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + >+ " ^\n" + >+ "The interface I cannot be implemented more than once with different arguments: I and I<U>\n" + >+ "----------\n", >+ null /* no extra class libraries */, >+ true /* flush output directory */, >+ customOptions); >+} > }
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 77918
:
71591
|
82360
|
82461