Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 77918 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+7 lines)
Lines 108-113 Link Here
108
 * 								   NullLocalVariableInstanceofYieldsFalse
108
 * 								   NullLocalVariableInstanceofYieldsFalse
109
 * 								   RedundantNullCheckOnNonNullLocalVariable
109
 * 								   RedundantNullCheckOnNonNullLocalVariable
110
 * 								   NonNullLocalVariableComparisonYieldsFalse
110
 * 								   NonNullLocalVariableComparisonYieldsFalse
111
 *     IBM Corporation - added the following constants
112
 *								   RedundantSuperInterface
111
 *******************************************************************************/
113
 *******************************************************************************/
112
package org.eclipse.jdt.core.compiler;
114
package org.eclipse.jdt.core.compiler;
113
 
115
 
Lines 611-616 Link Here
611
	int ObjectCannotHaveSuperTypes = Internal + 329;
613
	int ObjectCannotHaveSuperTypes = Internal + 329;
612
	/** @since 3.1 */
614
	/** @since 3.1 */
613
	int ObjectMustBeClass = Internal + 330;
615
	int ObjectMustBeClass = Internal + 330;
616
	// non-deprecated, non-generic type related problems continue at 660
614
617
615
	/** @deprecated - problem is no longer generated, use {@link #UndefinedType} instead */
618
	/** @deprecated - problem is no longer generated, use {@link #UndefinedType} instead */
616
	int SuperclassNotFound =  TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
619
	int SuperclassNotFound =  TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
Lines 1171-1176 Link Here
1171
	/** @since 3.3 */
1174
	/** @since 3.3 */
1172
	int MethodMustOverrideOrImplement = MethodRelated + 634;
1175
	int MethodMustOverrideOrImplement = MethodRelated + 634;
1173
	
1176
	
1177
	// non-generic type related, cont'd
1178
	/** @since 3.4 */
1179
	int RedundantSuperInterface = TypeRelated + 660;
1180
	
1174
	/**
1181
	/**
1175
	 * Corrupted binaries
1182
	 * Corrupted binaries
1176
	 */
1183
	 */
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+3 lines)
Lines 542-547 Link Here
542
633 = The value for annotation attribute {0}.{1} must be an enum constant expression
542
633 = The value for annotation attribute {0}.{1} must be an enum constant expression
543
634 = The method {0}({1}) of type {2} must override or implement a supertype method
543
634 = The method {0}({1}) of type {2} must override or implement a supertype method
544
544
545
### TYPES CONT'D
546
660 = Redundant interface {0} for the type {1}
547
545
### CORRUPTED BINARIES
548
### CORRUPTED BINARIES
546
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
549
700 = The class file {0} contains a signature ''{1}'' ill-formed at position {2}
547
550
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +20 lines)
Lines 293-298 Link Here
293
			
293
			
294
		case IProblem.OverridingMethodWithoutSuperInvocation:
294
		case IProblem.OverridingMethodWithoutSuperInvocation:
295
			return CompilerOptions.OverridingMethodWithoutSuperInvocation;
295
			return CompilerOptions.OverridingMethodWithoutSuperInvocation;
296
		
297
		case IProblem.RedundantSuperInterface:
298
			return CompilerOptions.RedundantInterface;
296
	}
299
	}
297
	return 0;
300
	return 0;
298
}
301
}
Lines 391-396 Link Here
391
					
394
					
392
				case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
395
				case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
393
				case (int)(CompilerOptions.UnusedLabel >>> 32):
396
				case (int)(CompilerOptions.UnusedLabel >>> 32):
397
				case (int)(CompilerOptions.RedundantInterface >>> 32):
394
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
398
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
395
399
396
				case (int)(CompilerOptions.ForbiddenReference >>> 32):
400
				case (int)(CompilerOptions.ForbiddenReference >>> 32):
Lines 5529-5535 Link Here
5529
		localDecl.sourceStart,
5533
		localDecl.sourceStart,
5530
		localDecl.sourceEnd);
5534
		localDecl.sourceEnd);
5531
}
5535
}
5532
5536
public void redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superType) {
5537
	int severity = computeSeverity(IProblem.RedundantSuperInterface);
5538
	if (severity != ProblemSeverities.Ignore) {
5539
		this.handle(
5540
			IProblem.RedundantSuperInterface,
5541
			new String[] {
5542
				new String(superType.readableName()),
5543
				new String(type.sourceName())},
5544
			new String[] {
5545
				new String(superType.shortReadableName()),
5546
				new String(type.sourceName())},
5547
			severity,
5548
			reference.sourceStart,
5549
			reference.sourceEnd);
5550
	}
5551
}
5533
public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
5552
public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
5534
	this.handle(
5553
	this.handle(
5535
		IProblem.ArrayReferenceRequired,
5554
		IProblem.ArrayReferenceRequired,
(-)model/org/eclipse/jdt/core/JavaCore.java (+16 lines)
Lines 68-73 Link Here
68
 *                                 COMPILER_PB_REDUNDANT_NULL_CHECK
68
 *                                 COMPILER_PB_REDUNDANT_NULL_CHECK
69
 *     IBM Corporation - added the following constants:
69
 *     IBM Corporation - added the following constants:
70
 *                                 COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE
70
 *                                 COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE
71
 *     IBM Corporation - added the following constants:
72
 *                                 COMPILER_PB_REDUNDANT_INTERFACE
71
 *******************************************************************************/
73
 *******************************************************************************/
72
package org.eclipse.jdt.core;
74
package org.eclipse.jdt.core;
73
75
Lines 709-714 Link Here
709
	/**
711
	/**
710
	 * Possible  configurable option ID.
712
	 * Possible  configurable option ID.
711
	 * @see #getDefaultOptions()
713
	 * @see #getDefaultOptions()
714
	 * @since 3.4
715
	 */
716
	public static final String COMPILER_PB_REDUNDANT_INTERFACE = PLUGIN_ID + ".compiler.problem.redundantInterface"; //$NON-NLS-1$
717
	/**
718
	 * Possible  configurable option ID.
719
	 * @see #getDefaultOptions()
712
	 */
720
	 */
713
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
721
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
714
	/**
722
	/**
Lines 2482-2487 Link Here
2482
	 *     - possible values:   { "error", "warning", "ignore" }
2490
	 *     - possible values:   { "error", "warning", "ignore" }
2483
	 *     - default:           "ignore"
2491
	 *     - default:           "ignore"
2484
	 *
2492
	 *
2493
	 * COMPILER / Reporting Redundant Super Interface
2494
	 *    When enabled, the compiler will issue an error or a warning if a class
2495
	 *    explicitly implements an interface that is already implemented by any 
2496
	 *    of its superclasses.
2497
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.redundantInterface"
2498
	 *     - possible values:   { "error", "warning", "ignore" }
2499
	 *     - default:           "ignore"
2500
	 *
2485
	 * BUILDER / Specifying Filters for Resource Copying Control
2501
	 * BUILDER / Specifying Filters for Resource Copying Control
2486
	 *    Allow to specify some filters to control the resource copy process.
2502
	 *    Allow to specify some filters to control the resource copy process.
2487
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2503
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-5 / +32 lines)
Lines 113-118 Link Here
113
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
113
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
114
	public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
114
	public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
115
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
115
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
116
	public static final String OPTION_ReportRedundantSuperInterface =  "org.eclipse.jdt.core.compiler.problem.redundantInterface"; //$NON-NLS-1$
116
117
117
	// Backward compatibility
118
	// Backward compatibility
118
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
119
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 199-204 Link Here
199
	public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L;
200
	public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L;
200
	public static final long PotentialNullReference = ASTNode.Bit51L;
201
	public static final long PotentialNullReference = ASTNode.Bit51L;
201
	public static final long RedundantNullCheck = ASTNode.Bit52L;
202
	public static final long RedundantNullCheck = ASTNode.Bit52L;
203
	public static final long RedundantInterface = ASTNode.Bit53L;
202
204
203
	// Map: String optionKey --> Long irritant>
205
	// Map: String optionKey --> Long irritant>
204
	private static Map OptionToIrritants;
206
	private static Map OptionToIrritants;
Lines 434-439 Link Here
434
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
436
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
435
		optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED);
437
		optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED);
436
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
438
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
439
		optionsMap.put(OPTION_ReportRedundantSuperInterface, getSeverityString(RedundantInterface));
437
		return optionsMap;
440
		return optionsMap;
438
	}
441
	}
439
442
Lines 556-561 Link Here
556
					return OPTION_ReportFallthroughCase;
559
					return OPTION_ReportFallthroughCase;
557
				case (int)(OverridingMethodWithoutSuperInvocation >>> 32) :
560
				case (int)(OverridingMethodWithoutSuperInvocation >>> 32) :
558
					return OPTION_ReportOverridingMethodWithoutSuperInvocation;
561
					return OPTION_ReportOverridingMethodWithoutSuperInvocation;
562
				case (int)(RedundantInterface >>> 32) :
563
					return OPTION_ReportRedundantSuperInterface;
559
			}
564
			}
560
		}
565
		}
561
		return null;
566
		return null;
Lines 823-828 Link Here
823
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
828
		if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue);
824
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
829
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
825
		if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
830
		if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
831
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperInterface)) != null) updateSeverity(RedundantInterface, optionValue);
826
832
827
		// Javadoc options
833
		// Javadoc options
828
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
834
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 1010-1015 Link Here
1010
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1016
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1011
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1017
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1012
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1018
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1019
		buf.append("\n\t- redundant interface: ").append(getSeverityString(RedundantInterface)); //$NON-NLS-1$
1013
		return buf.toString();
1020
		return buf.toString();
1014
	}
1021
	}
1015
1022
Lines 1093-1099 Link Here
1093
	/**
1100
	/**
1094
	 * Return all warning option names for use as keys in compiler options maps.
1101
	 * Return all warning option names for use as keys in compiler options maps.
1095
	 * @return all warning option names
1102
	 * @return all warning option names
1096
	 * TODO (maxime) revise for ensuring completeness
1097
	 */
1103
	 */
1098
	public static String[] warningOptionNames() {
1104
	public static String[] warningOptionNames() {
1099
		String[] result = {
1105
		String[] result = {
Lines 1101-1106 Link Here
1101
			OPTION_ReportAssertIdentifier,
1107
			OPTION_ReportAssertIdentifier,
1102
			OPTION_ReportAutoboxing,
1108
			OPTION_ReportAutoboxing,
1103
			OPTION_ReportDeprecation,
1109
			OPTION_ReportDeprecation,
1110
			OPTION_ReportDeprecationInDeprecatedCode,
1111
			OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
1104
			OPTION_ReportDiscouragedReference,
1112
			OPTION_ReportDiscouragedReference,
1105
			OPTION_ReportEmptyStatement,
1113
			OPTION_ReportEmptyStatement,
1106
			OPTION_ReportEnumIdentifier,
1114
			OPTION_ReportEnumIdentifier,
Lines 1113-1124 Link Here
1113
			OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
1121
			OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
1114
			OPTION_ReportIncompleteEnumSwitch,
1122
			OPTION_ReportIncompleteEnumSwitch,
1115
			OPTION_ReportIndirectStaticAccess,
1123
			OPTION_ReportIndirectStaticAccess,
1124
			OPTION_ReportInvalidAnnotation,
1116
			OPTION_ReportInvalidJavadoc,
1125
			OPTION_ReportInvalidJavadoc,
1126
			OPTION_ReportInvalidJavadocTags,
1127
			OPTION_ReportInvalidJavadocTagsDeprecatedRef,
1128
			OPTION_ReportInvalidJavadocTagsNotVisibleRef,
1129
			OPTION_ReportInvalidJavadocTagsVisibility,
1117
			OPTION_ReportLocalVariableHiding,
1130
			OPTION_ReportLocalVariableHiding,
1118
			OPTION_ReportMethodWithConstructorName,
1131
			OPTION_ReportMethodWithConstructorName,
1132
			OPTION_ReportMissingAnnotation,
1119
			OPTION_ReportMissingDeprecatedAnnotation,
1133
			OPTION_ReportMissingDeprecatedAnnotation,
1134
			OPTION_ReportMissingJavadoc,
1120
			OPTION_ReportMissingJavadocComments,
1135
			OPTION_ReportMissingJavadocComments,
1136
			OPTION_ReportMissingJavadocCommentsOverriding,
1137
			OPTION_ReportMissingJavadocCommentsVisibility,
1121
			OPTION_ReportMissingJavadocTags,
1138
			OPTION_ReportMissingJavadocTags,
1139
			OPTION_ReportMissingJavadocTagsOverriding,
1140
			OPTION_ReportMissingJavadocTagsVisibility,
1122
			OPTION_ReportMissingOverrideAnnotation,
1141
			OPTION_ReportMissingOverrideAnnotation,
1123
			OPTION_ReportMissingSerialVersion,
1142
			OPTION_ReportMissingSerialVersion,
1124
			OPTION_ReportNoEffectAssignment,
1143
			OPTION_ReportNoEffectAssignment,
Lines 1126-1151 Link Here
1126
			OPTION_ReportNonExternalizedStringLiteral,
1145
			OPTION_ReportNonExternalizedStringLiteral,
1127
			OPTION_ReportNonStaticAccessToStatic,
1146
			OPTION_ReportNonStaticAccessToStatic,
1128
			OPTION_ReportNullReference,
1147
			OPTION_ReportNullReference,
1129
			OPTION_ReportPotentialNullReference,
1148
			OPTION_ReportOverridingMethodWithoutSuperInvocation,
1130
			OPTION_ReportRedundantNullCheck,
1131
			OPTION_ReportOverridingPackageDefaultMethod,
1149
			OPTION_ReportOverridingPackageDefaultMethod,
1132
			OPTION_ReportParameterAssignment,
1150
			OPTION_ReportParameterAssignment,
1133
			OPTION_ReportPossibleAccidentalBooleanAssignment,
1151
			OPTION_ReportPossibleAccidentalBooleanAssignment,
1152
			OPTION_ReportPotentialNullReference,
1153
			OPTION_ReportRawTypeReference,
1154
			OPTION_ReportRedundantNullCheck,
1155
			OPTION_ReportRedundantSuperInterface,
1156
			OPTION_ReportSpecialParameterHidingField,
1134
			OPTION_ReportSyntheticAccessEmulation,
1157
			OPTION_ReportSyntheticAccessEmulation,
1135
			OPTION_ReportTypeParameterHiding,
1158
			OPTION_ReportTypeParameterHiding,
1136
			OPTION_ReportUncheckedTypeOperation,
1159
			OPTION_ReportUncheckedTypeOperation,
1137
			OPTION_ReportUndocumentedEmptyBlock,
1160
			OPTION_ReportUndocumentedEmptyBlock,
1161
			OPTION_ReportUnhandledWarningToken,
1138
			OPTION_ReportUnnecessaryElse,
1162
			OPTION_ReportUnnecessaryElse,
1139
			OPTION_ReportUnnecessaryTypeCheck,
1163
			OPTION_ReportUnnecessaryTypeCheck,
1140
			OPTION_ReportUnqualifiedFieldAccess,
1164
			OPTION_ReportUnqualifiedFieldAccess,
1141
			OPTION_ReportUnusedDeclaredThrownException,
1165
			OPTION_ReportUnusedDeclaredThrownException,
1166
			OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding,
1142
			OPTION_ReportUnusedImport,
1167
			OPTION_ReportUnusedImport,
1168
			OPTION_ReportUnusedLabel,
1143
			OPTION_ReportUnusedLocal,
1169
			OPTION_ReportUnusedLocal,
1144
			OPTION_ReportUnusedParameter,
1170
			OPTION_ReportUnusedParameter,
1171
			OPTION_ReportUnusedParameterIncludeDocCommentReference,
1172
			OPTION_ReportUnusedParameterWhenImplementingAbstract,
1173
			OPTION_ReportUnusedParameterWhenOverridingConcrete,
1145
			OPTION_ReportUnusedPrivateMember,
1174
			OPTION_ReportUnusedPrivateMember,
1146
			OPTION_ReportVarargsArgumentNeedCast,
1175
			OPTION_ReportVarargsArgumentNeedCast,
1147
			OPTION_ReportUnhandledWarningToken,
1148
			OPTION_ReportOverridingMethodWithoutSuperInvocation
1149
		};
1176
		};
1150
		return result;
1177
		return result;
1151
	}
1178
	}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-3 / +58 lines)
Lines 23-30 Link Here
23
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
23
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
24
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
24
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
25
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
25
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
26
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
26
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
27
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
27
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
28
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
29
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
28
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
30
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
29
31
30
public class ClassScope extends Scope {
32
public class ClassScope extends Scope {
Lines 766-771 Link Here
766
			currentType.tagBits |= TagBits.HasNoMemberTypes;
768
			currentType.tagBits |= TagBits.HasNoMemberTypes;
767
		} while ((currentType = currentType.superclass()) != null && (currentType.tagBits & TagBits.HasNoMemberTypes) == 0);
769
		} while ((currentType = currentType.superclass()) != null && (currentType.tagBits & TagBits.HasNoMemberTypes) == 0);
768
	}
770
	}
771
	
772
	private	void checkForRedundantInterfaces() {
773
		ReferenceBinding[] superInterfaces = 
774
				this.referenceContext.binding.superInterfaces;
775
		if (superInterfaces.length > 0) {
776
			// collect redundant interfaces
777
			int length = superInterfaces.length;
778
			boolean[] superInterfaceIsRedundant = null;
779
			for (ReferenceBinding current = this.referenceContext.binding.superclass(); 
780
					current != null; current = current.superclass()) {
781
				ReferenceBinding[] checkedInterfaces = current.superInterfaces();
782
				if (checkedInterfaces == null) { // hierarchy cycle - may get rid of this depending on bug 192620
783
					break;
784
				} else if (checkedInterfaces.length == 0) {
785
					continue;
786
				}
787
				nextInterface: for (int i = 0; i < length; i++) {
788
					if (superInterfaceIsRedundant == null || 
789
							! superInterfaceIsRedundant[i]) {
790
						for (int j = checkedInterfaces.length - 1; j >= 0; j--) {
791
							if (superInterfaces[i] == checkedInterfaces[j]) {
792
								if (superInterfaceIsRedundant == null) {
793
									superInterfaceIsRedundant = new boolean[length];
794
								}
795
								superInterfaceIsRedundant[i] = true;
796
								continue nextInterface;
797
							}
798
						}
799
					}
800
				}
801
			}
802
			// complain if needed
803
			if (superInterfaceIsRedundant != null) {
804
				for (int i = 0; i < length; i++) {
805
					if (superInterfaceIsRedundant[i]) {
806
						// skip duplicates on the reference context
807
						int j = i;
808
						while (this.referenceContext.superInterfaces[j].resolvedType != superInterfaces[i]) {
809
							j++;
810
						}
811
						problemReporter().redundantSuperInterface(this.referenceContext.binding, this.referenceContext.superInterfaces[j], superInterfaces[i]);
812
					}
813
				}
814
			}
815
		}
816
	}
769
817
770
	// Perform deferred bound checks for parameterized type references (only done after hierarchy is connected)
818
	// Perform deferred bound checks for parameterized type references (only done after hierarchy is connected)
771
	public void  checkParameterizedTypeBounds() {
819
	public void  checkParameterizedTypeBounds() {
Lines 948-954 Link Here
948
	}
996
	}
949
	
997
	
950
	void connectTypeHierarchy() {
998
	void connectTypeHierarchy() {
951
		SourceTypeBinding sourceType = referenceContext.binding;
999
	SourceTypeBinding sourceType = referenceContext.binding;
952
		if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) == 0) {
1000
		if ((sourceType.tagBits & TagBits.BeginHierarchyCheck) == 0) {
953
			sourceType.tagBits |= TagBits.BeginHierarchyCheck;
1001
			sourceType.tagBits |= TagBits.BeginHierarchyCheck;
954
			boolean noProblems = connectSuperclass();
1002
			boolean noProblems = connectSuperclass();
Lines 956-963 Link Here
956
			sourceType.tagBits |= TagBits.EndHierarchyCheck;
1004
			sourceType.tagBits |= TagBits.EndHierarchyCheck;
957
			noProblems &= connectTypeVariables(referenceContext.typeParameters, false);
1005
			noProblems &= connectTypeVariables(referenceContext.typeParameters, false);
958
			sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
1006
			sourceType.tagBits |= TagBits.TypeVariablesAreConnected;
959
			if (noProblems && sourceType.isHierarchyInconsistent())
1007
			if (noProblems) {
960
				problemReporter().hierarchyHasProblems(sourceType);
1008
				if (sourceType.isHierarchyInconsistent()) {
1009
					problemReporter().hierarchyHasProblems(sourceType);
1010
				} else if (!sourceType.isInterface() && 
1011
						compilerOptions().getSeverity(CompilerOptions.RedundantInterface) 
1012
				!= ProblemSeverities.Ignore){
1013
					checkForRedundantInterfaces();
1014
				}
1015
			}
961
		}
1016
		}
962
		connectMemberTypes();
1017
		connectMemberTypes();
963
		LookupEnvironment env = environment();
1018
		LookupEnvironment env = environment();
(-)src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java (+198 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import java.util.Map;
14
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
13
import junit.framework.Test;
17
import junit.framework.Test;
14
18
15
public class SuperTypeTest extends AbstractRegressionTest {
19
public class SuperTypeTest extends AbstractRegressionTest {
Lines 263-266 Link Here
263
		"----------\n"
267
		"----------\n"
264
	);
268
	);
265
}
269
}
270
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
271
// default is silent
272
public void test008() {
273
	this.runConformTest(
274
		new String[] {
275
			"X.java",
276
			"public class X implements I {\n" + 
277
			"}\n" + 
278
			"interface I {\n" + 
279
			"}\n" + 
280
			"interface J {\n" + 
281
			"}\n" + 
282
			"class Y extends X implements I, J {\n" + 
283
			"}"
284
		},
285
		""
286
	);
287
}
288
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
289
// raising an error
290
public void test009() {
291
	Map customOptions = getCompilerOptions();
292
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
293
			CompilerOptions.ERROR);
294
	this.runNegativeTest(
295
		new String[] {
296
			"X.java",
297
			"public class X implements I {\n" + 
298
			"}\n" + 
299
			"interface I {\n" + 
300
			"}\n" + 
301
			"interface J {\n" + 
302
			"}\n" + 
303
			"class Y extends X implements I, J {\n" + 
304
			"}"
305
		},
306
		"----------\n" + 
307
		"1. ERROR in X.java (at line 7)\n" + 
308
		"	class Y extends X implements I, J {\n" + 
309
		"	                             ^\n" + 
310
		"Redundant interface I for the type Y\n" + 
311
		"----------\n",
312
		null /* no extra class libraries */, 
313
		true /* flush output directory */, 
314
		customOptions);
315
}
316
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
317
// raising an error - with true duplicates
318
public void test010() {
319
	Map customOptions = getCompilerOptions();
320
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
321
			CompilerOptions.ERROR);
322
	this.runNegativeTest(
323
		new String[] {
324
			"X.java",
325
			"public class X implements I {\n" + 
326
			"}\n" + 
327
			"interface I {\n" + 
328
			"}\n" + 
329
			"interface J {\n" + 
330
			"}\n" + 
331
			"class Y extends X implements I, J, I {\n" + 
332
			"}"
333
		},
334
		"----------\n" + 
335
		"1. ERROR in X.java (at line 7)\n" + 
336
		"	class Y extends X implements I, J, I {\n" + 
337
		"	                             ^\n" + 
338
		"Redundant interface I for the type Y\n" + 
339
		"----------\n" + 
340
		"2. ERROR in X.java (at line 7)\n" + 
341
		"	class Y extends X implements I, J, I {\n" + 
342
		"	                                   ^\n" + 
343
		"Duplicate interface I for the type Y\n" + 
344
		"----------\n",
345
		null /* no extra class libraries */, 
346
		true /* flush output directory */, 
347
		customOptions);
348
}
349
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
350
// raising an error - deeper hierarchy
351
public void test011() {
352
	Map customOptions = getCompilerOptions();
353
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
354
			CompilerOptions.ERROR);
355
	this.runNegativeTest(
356
		new String[] {
357
			"X.java",
358
			"public class X implements I {\n" + 
359
			"}\n" + 
360
			"interface I {\n" + 
361
			"}\n" + 
362
			"interface J {\n" + 
363
			"}\n" + 
364
			"class Y extends X {\n" + 
365
			"}\n" + 
366
			"class Z extends Y implements J, I {\n" + 
367
			"}"
368
		},
369
		"----------\n" + 
370
		"1. ERROR in X.java (at line 9)\n" + 
371
		"	class Z extends Y implements J, I {\n" + 
372
		"	                                ^\n" + 
373
		"Redundant interface I for the type Z\n" + 
374
		"----------\n",
375
		null /* no extra class libraries */, 
376
		true /* flush output directory */, 
377
		customOptions);
378
}
379
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
380
// no error - deeper hierarchy
381
public void test012() {
382
	Map customOptions = getCompilerOptions();
383
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
384
			CompilerOptions.ERROR);
385
	this.runConformTest(
386
		new String[] {
387
			"X.java",
388
			"public class X implements I {\n" + 
389
			"}\n" + 
390
			"interface I {\n" + 
391
			"}\n" + 
392
			"interface J {\n" + 
393
			"}\n" + 
394
			"class Y extends X implements J {\n" + 
395
			"}\n" + 
396
			"class Z extends Y {\n" + 
397
			"}"
398
		},
399
		"",
400
		null /* no extra class libraries */, 
401
		true /* flush output directory */, 
402
		null /* no vm arguments */,
403
		customOptions,
404
		null /* no custom requestor*/);
405
}
406
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
407
// no error - extending interfaces
408
// deliberate choice so far: no attempt to detect that since J extends I,
409
// implementing I is redundant
410
public void test013() {
411
	Map customOptions = getCompilerOptions();
412
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
413
			CompilerOptions.ERROR);
414
	this.runConformTest(
415
		new String[] {
416
			"X.java",
417
			"public class X implements J {\n" + 
418
			"}\n" + 
419
			"interface I {\n" + 
420
			"}\n" + 
421
			"interface J extends I {\n" + 
422
			"}\n" + 
423
			"class Y extends X implements I {\n" + 
424
			"}\n"
425
		},
426
		"",
427
		null /* no extra class libraries */, 
428
		true /* flush output directory */, 
429
		null /* no vm arguments */,
430
		customOptions,
431
		null /* no custom requestor*/);
432
}
433
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
434
// error due to cycles (guarding the null case)
435
public void test014() {
436
	Map customOptions = getCompilerOptions();
437
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
438
			CompilerOptions.ERROR);
439
	this.runNegativeTest(
440
		new String[] {
441
			"X.java",
442
			"public class X {\n" + 
443
			"}\n" + 
444
			"interface I {\n" + 
445
			"}\n",  
446
			"CycleParent.java", 
447
			"class CycleParent extends CycleBase<CycleChild> {\n" + 
448
			"}\n",  
449
			"CycleBase.java",
450
			"class CycleBase<T extends CycleBase> {\n" + 
451
			"}\n",  
452
			"CycleChild.java",
453
			"class CycleChild extends CycleParent implements Comparable<CycleChild> {\n" + 
454
			"  public int compareTo(CycleChild o) { \n" + 
455
			"    return 0; \n" + 
456
			"  }\n" + 
457
			"}"
458
		},
459
		"ERR",
460
		null /* no extra class libraries */, 
461
		true /* flush output directory */, 
462
		customOptions);
463
}
266
}
464
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+1 lines)
Lines 1268-1273 Link Here
1268
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" +
1268
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" +
1269
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" +
1269
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" +
1270
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" +
1270
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" +
1271
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantInterface\" value=\"ignore\"/>\n" +
1271
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" +
1272
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" +
1272
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" +
1273
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" +
1273
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" +
1274
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" +
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+152 lines)
Lines 38019-38022 Link Here
38019
		"Cycle detected: the type X cannot extend/implement itself or one of its own member types\n" + 
38019
		"Cycle detected: the type X cannot extend/implement itself or one of its own member types\n" + 
38020
		"----------\n");
38020
		"----------\n");
38021
}
38021
}
38022
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
38023
// generic variants
38024
public void test1142() {
38025
	Map customOptions = getCompilerOptions();
38026
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
38027
			CompilerOptions.ERROR);
38028
	customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, 
38029
			CompilerOptions.IGNORE);
38030
	this.runNegativeTest(
38031
		new String[] {
38032
			"X.java",
38033
			"public class X implements I {\n" + 
38034
			"}\n" + 
38035
			"interface I <T> {\n" + 
38036
			"}\n" + 
38037
			"interface J {\n" + 
38038
			"}\n" + 
38039
			"class Y extends X implements I, J {\n" + 
38040
			"}"
38041
		},
38042
		"----------\n" + 
38043
		"1. ERROR in X.java (at line 7)\n" + 
38044
		"	class Y extends X implements I, J {\n" + 
38045
		"	                             ^\n" + 
38046
		"Redundant interface I for the type Y\n" + 
38047
		"----------\n",
38048
		null /* no extra class libraries */, 
38049
		true /* flush output directory */, 
38050
		customOptions);
38051
}
38052
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
38053
// generic variants
38054
public void test1143() {
38055
	Map customOptions = getCompilerOptions();
38056
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
38057
			CompilerOptions.ERROR);
38058
	this.runNegativeTest(
38059
		new String[] {
38060
			"X.java",
38061
			"public class X implements I<Object> {\n" + 
38062
			"}\n" + 
38063
			"interface I <T> {\n" + 
38064
			"}\n" + 
38065
			"interface J {\n" + 
38066
			"}\n" + 
38067
			"class Y extends X implements I<Object>, J {\n" + 
38068
			"}"
38069
		},
38070
		"----------\n" + 
38071
		"1. ERROR in X.java (at line 7)\n" + 
38072
		"	class Y extends X implements I<Object>, J {\n" + 
38073
		"	                             ^\n" + 
38074
		"Redundant interface I<Object> for the type Y\n" + 
38075
		"----------\n",
38076
		null /* no extra class libraries */, 
38077
		true /* flush output directory */, 
38078
		customOptions);
38079
}
38080
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
38081
// generic variants
38082
public void test1144() {
38083
	Map customOptions = getCompilerOptions();
38084
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
38085
			CompilerOptions.ERROR);
38086
	this.runNegativeTest(
38087
		new String[] {
38088
			"X.java",
38089
			"public class X<T> implements I<T> {\n" + 
38090
			"}\n" + 
38091
			"interface I <T> {\n" + 
38092
			"}\n" + 
38093
			"interface J {\n" + 
38094
			"}\n" + 
38095
			"class Y<T extends Z> extends X<T> implements I<T>, J {\n" + 
38096
			"}\n" +
38097
			"class Z {\n" + 
38098
			"}"
38099
		},
38100
		"----------\n" + 
38101
		"1. ERROR in X.java (at line 7)\n" + 
38102
		"	class Y<T extends Z> extends X<T> implements I<T>, J {\n" + 
38103
		"	                                             ^\n" + 
38104
		"Redundant interface I<T> for the type Y\n" + 
38105
		"----------\n",
38106
		null /* no extra class libraries */, 
38107
		true /* flush output directory */, 
38108
		customOptions);
38109
}
38110
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
38111
// generic variants - the 'different arguments' error overrides the
38112
// redundant error
38113
public void test1145() {
38114
	Map customOptions = getCompilerOptions();
38115
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
38116
			CompilerOptions.ERROR);
38117
	this.runNegativeTest(
38118
		new String[] {
38119
			"X.java",
38120
			"public class X<T> implements I<T> {\n" + 
38121
			"}\n" + 
38122
			"interface I <T> {\n" + 
38123
			"}\n" + 
38124
			"interface J {\n" + 
38125
			"}\n" + 
38126
			"class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + 
38127
			"}\n" +
38128
			"class Z {\n" + 
38129
			"}"
38130
		},
38131
		"----------\n" + 
38132
		"1. ERROR in X.java (at line 7)\n" + 
38133
		"	class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + 
38134
		"	      ^\n" + 
38135
		"The interface I cannot be implemented more than once with different arguments: I<T> and I<U>\n" + 
38136
		"----------\n",
38137
		null /* no extra class libraries */, 
38138
		true /* flush output directory */, 
38139
		customOptions);
38140
}
38141
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
38142
// generic variants - the 'different arguments' error overrides the
38143
// redundant error
38144
public void test1146() {
38145
	Map customOptions = getCompilerOptions();
38146
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperInterface, 
38147
			CompilerOptions.ERROR);
38148
	customOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, 
38149
			CompilerOptions.IGNORE);
38150
	this.runNegativeTest(
38151
		new String[] {
38152
			"X.java",
38153
			"public class X<T> implements I {\n" + 
38154
			"}\n" + 
38155
			"interface I <T> {\n" + 
38156
			"}\n" + 
38157
			"interface J {\n" + 
38158
			"}\n" + 
38159
			"class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + 
38160
			"}\n" +
38161
			"class Z {\n" + 
38162
			"}"
38163
		},
38164
		"----------\n" + 
38165
		"1. ERROR in X.java (at line 7)\n" + 
38166
		"	class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {\n" + 
38167
		"	      ^\n" + 
38168
		"The interface I cannot be implemented more than once with different arguments: I and I<U>\n" + 
38169
		"----------\n",
38170
		null /* no extra class libraries */, 
38171
		true /* flush output directory */, 
38172
		customOptions);
38173
}
38022
}
38174
}

Return to bug 77918