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 (+4 lines)
Lines 111-116 Link Here
111
 *     IBM Corporation - added the following constants
111
 *     IBM Corporation - added the following constants
112
 *                                 InvalidUsageOfTypeParametersForAnnotationDeclaration
112
 *                                 InvalidUsageOfTypeParametersForAnnotationDeclaration
113
 *                                 InvalidUsageOfTypeParametersForEnumDeclaration
113
 *                                 InvalidUsageOfTypeParametersForEnumDeclaration
114
 *     IBM Corporation - added the following constants
115
 *								   RedundantSuperinterface
114
 *******************************************************************************/
116
 *******************************************************************************/
115
package org.eclipse.jdt.core.compiler;
117
package org.eclipse.jdt.core.compiler;
116
 
118
 
Lines 614-619 Link Here
614
	int ObjectCannotHaveSuperTypes = Internal + 329;
616
	int ObjectCannotHaveSuperTypes = Internal + 329;
615
	/** @since 3.1 */
617
	/** @since 3.1 */
616
	int ObjectMustBeClass = Internal + 330;
618
	int ObjectMustBeClass = Internal + 330;
619
	/** @since 3.4 */
620
	int RedundantSuperinterface = TypeRelated + 331;
617
621
618
	/** @deprecated - problem is no longer generated, use {@link #UndefinedType} instead */
622
	/** @deprecated - problem is no longer generated, use {@link #UndefinedType} instead */
619
	int SuperclassNotFound =  TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
623
	int SuperclassNotFound =  TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 251-256 Link Here
251
328 = The declared package "{1}" does not match the expected package "{0}"
251
328 = The declared package "{1}" does not match the expected package "{0}"
252
329 = The type java.lang.Object cannot have a superclass or superinterfaces
252
329 = The type java.lang.Object cannot have a superclass or superinterfaces
253
330 = The type java.lang.Object must be a class
253
330 = The type java.lang.Object must be a class
254
331 = Redundant superinterface {0} for the type {1}, already defined by {2}
254
255
255
###[obsolete] 330 = {0} cannot be resolved or is not a valid superclass
256
###[obsolete] 330 = {0} cannot be resolved or is not a valid superclass
256
###[obsolete] 331 = Superclass {0} is not visible
257
###[obsolete] 331 = Superclass {0} is not visible
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +22 lines)
Lines 311-316 Link Here
311
		case IProblem.UnusedTypeArgumentsForMethodInvocation:
311
		case IProblem.UnusedTypeArgumentsForMethodInvocation:
312
		case IProblem.UnusedTypeArgumentsForConstructorInvocation:
312
		case IProblem.UnusedTypeArgumentsForConstructorInvocation:
313
			return CompilerOptions.UnusedTypeArguments;
313
			return CompilerOptions.UnusedTypeArguments;
314
315
		case IProblem.RedundantSuperinterface:
316
			return CompilerOptions.RedundantSuperinterface;
314
	}
317
	}
315
	return 0;
318
	return 0;
316
}
319
}
Lines 409-414 Link Here
409
					
412
					
410
				case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
413
				case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
411
				case (int)(CompilerOptions.UnusedLabel >>> 32):
414
				case (int)(CompilerOptions.UnusedLabel >>> 32):
415
				case (int)(CompilerOptions.RedundantSuperinterface >>> 32):
412
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
416
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
413
417
414
				case (int)(CompilerOptions.ForbiddenReference >>> 32):
418
				case (int)(CompilerOptions.ForbiddenReference >>> 32):
Lines 5707-5713 Link Here
5707
		localDecl.sourceStart,
5711
		localDecl.sourceStart,
5708
		localDecl.sourceEnd);
5712
		localDecl.sourceEnd);
5709
}
5713
}
5710
5714
public void redundantSuperInterface(SourceTypeBinding type, TypeReference reference, ReferenceBinding superinterface, ReferenceBinding declaringType) {
5715
	int severity = computeSeverity(IProblem.RedundantSuperinterface);
5716
	if (severity != ProblemSeverities.Ignore) {
5717
		this.handle(
5718
			IProblem.RedundantSuperinterface,
5719
			new String[] {
5720
				new String(superinterface.readableName()),
5721
				new String(type.readableName()),
5722
				new String(declaringType.readableName())},
5723
			new String[] {
5724
				new String(superinterface.shortReadableName()),
5725
				new String(type.shortReadableName()),
5726
				new String(declaringType.shortReadableName())},
5727
			severity,
5728
			reference.sourceStart,
5729
			reference.sourceEnd);
5730
	}
5731
}
5711
public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
5732
public void referenceMustBeArrayTypeAt(TypeBinding arrayType, ArrayReference arrayRef) {
5712
	this.handle(
5733
	this.handle(
5713
		IProblem.ArrayReferenceRequired,
5734
		IProblem.ArrayReferenceRequired,
(-)model/org/eclipse/jdt/core/JavaCore.java (+16 lines)
Lines 75-80 Link Here
75
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_NO_TAG
75
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_NO_TAG
76
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_RETURN_TAG
76
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_RETURN_TAG
77
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS
77
 *								   COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS
78
 *     IBM Corporation - added the following constants:
79
 *                                 COMPILER_PB_REDUNDANT_SUPERINTERFACE
78
 *******************************************************************************/
80
 *******************************************************************************/
79
package org.eclipse.jdt.core;
81
package org.eclipse.jdt.core;
80
82
Lines 760-765 Link Here
760
	/**
762
	/**
761
	 * Possible  configurable option ID.
763
	 * Possible  configurable option ID.
762
	 * @see #getDefaultOptions()
764
	 * @see #getDefaultOptions()
765
	 * @since 3.4
766
	 */
767
	public static final String COMPILER_PB_REDUNDANT_SUPERINTERFACE = PLUGIN_ID + ".compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
768
	/**
769
	 * Possible  configurable option ID.
770
	 * @see #getDefaultOptions()
763
	 */
771
	 */
764
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
772
	public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
765
	/**
773
	/**
Lines 2610-2615 Link Here
2610
	 *     - possible values:   { "error", "warning", "ignore" }
2618
	 *     - possible values:   { "error", "warning", "ignore" }
2611
	 *     - default:           "warning"
2619
	 *     - default:           "warning"
2612
	 *     
2620
	 *     
2621
	 * COMPILER / Reporting Redundant Superinterface
2622
	 *    When enabled, the compiler will issue an error or a warning if a type
2623
	 *    explicitly implements an interface that is already implemented by any 
2624
	 *    of its supertypes.
2625
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"
2626
	 *     - possible values:   { "error", "warning", "ignore" }
2627
	 *     - default:           "ignore"
2628
	 *
2613
	 * BUILDER / Specifying Filters for Resource Copying Control
2629
	 * BUILDER / Specifying Filters for Resource Copying Control
2614
	 *    Allow to specify some filters to control the resource copy process.
2630
	 *    Allow to specify some filters to control the resource copy process.
2615
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
2631
	 *     - option id:         "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+8 lines)
Lines 117-122 Link Here
117
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
117
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
118
	public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
118
	public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
119
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
119
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
120
	public static final String OPTION_ReportRedundantSuperinterface =  "org.eclipse.jdt.core.compiler.problem.redundantSuperinterface"; //$NON-NLS-1$
120
121
121
	// Backward compatibility
122
	// Backward compatibility
122
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
123
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 210-215 Link Here
210
	public static final long MissingJavadocTagDescription = ASTNode.Bit53L;
211
	public static final long MissingJavadocTagDescription = ASTNode.Bit53L;
211
	public static final long UnusedTypeArguments = ASTNode.Bit54L;
212
	public static final long UnusedTypeArguments = ASTNode.Bit54L;
212
	public static final long UnusedWarningToken = ASTNode.Bit55L;
213
	public static final long UnusedWarningToken = ASTNode.Bit55L;
214
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
213
215
214
	// Map: String optionKey --> Long irritant>
216
	// Map: String optionKey --> Long irritant>
215
	private static Map OptionToIrritants;
217
	private static Map OptionToIrritants;
Lines 453-458 Link Here
453
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
455
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
454
		optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED);
456
		optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED);
455
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
457
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED);
458
		optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
456
		return optionsMap;
459
		return optionsMap;
457
	}
460
	}
458
461
Lines 581-586 Link Here
581
					return OPTION_ReportUnusedTypeArgumentsForMethodInvocation;
584
					return OPTION_ReportUnusedTypeArgumentsForMethodInvocation;
582
				case (int)(UnusedWarningToken >>> 32) :
585
				case (int)(UnusedWarningToken >>> 32) :
583
					return OPTION_ReportUnusedWarningToken;
586
					return OPTION_ReportUnusedWarningToken;
587
				case (int)(RedundantSuperinterface >>> 32) :
588
					return OPTION_ReportRedundantSuperinterface;
584
			}
589
			}
585
		}
590
		}
586
		return null;
591
		return null;
Lines 862-867 Link Here
862
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
867
		if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue);
863
		if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
868
		if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue);
864
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
869
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedTypeArgumentsForMethodInvocation)) != null) updateSeverity(UnusedTypeArguments, optionValue);
870
		if ((optionValue = optionsMap.get(OPTION_ReportRedundantSuperinterface)) != null) updateSeverity(RedundantSuperinterface, optionValue);
865
871
866
		// Javadoc options
872
		// Javadoc options
867
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
873
		if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
Lines 1056-1061 Link Here
1056
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1062
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1057
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1063
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1058
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1064
		buf.append("\n\t- unused type arguments for method/constructor invocation: ").append(getSeverityString(UnusedTypeArguments)); //$NON-NLS-1$
1065
		buf.append("\n\t- redundant superinterface: ").append(getSeverityString(RedundantSuperinterface)); //$NON-NLS-1$
1059
		return buf.toString();
1066
		return buf.toString();
1060
	}
1067
	}
1061
1068
Lines 1178-1183 Link Here
1178
			OPTION_ReportNullReference,
1185
			OPTION_ReportNullReference,
1179
			OPTION_ReportPotentialNullReference,
1186
			OPTION_ReportPotentialNullReference,
1180
			OPTION_ReportRedundantNullCheck,
1187
			OPTION_ReportRedundantNullCheck,
1188
			OPTION_ReportRedundantSuperinterface,
1181
			OPTION_ReportOverridingPackageDefaultMethod,
1189
			OPTION_ReportOverridingPackageDefaultMethod,
1182
			OPTION_ReportParameterAssignment,
1190
			OPTION_ReportParameterAssignment,
1183
			OPTION_ReportPossibleAccidentalBooleanAssignment,
1191
			OPTION_ReportPossibleAccidentalBooleanAssignment,
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (-2 / +63 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
11
package org.eclipse.jdt.internal.compiler.lookup;
12
12
13
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
13
import org.eclipse.jdt.internal.compiler.ast.*;
14
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
16
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
Lines 235-240 Link Here
235
void checkForBridgeMethod(MethodBinding currentMethod, MethodBinding inheritedMethod, MethodBinding[] allInheritedMethods) {
234
void checkForBridgeMethod(MethodBinding currentMethod, MethodBinding inheritedMethod, MethodBinding[] allInheritedMethods) {
236
	// no op before 1.5
235
	// no op before 1.5
237
}
236
}
237
void checkForRedundantSuperinterfaces(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
238
	if (superInterfaces == Binding.NO_SUPERINTERFACES) return;
239
240
	SimpleSet interfacesToCheck = new SimpleSet(superInterfaces.length);
241
	for (int i = 0, l = superInterfaces.length; i < l; i++)
242
		interfacesToCheck.add(superInterfaces[i]);
243
	ReferenceBinding[] itsInterfaces = null;
244
	SimpleSet inheritedInterfaces = new SimpleSet(5);
245
	ReferenceBinding superType = superclass;
246
	while (superType != null && superType.isValidBinding()) {
247
		if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
248
			for (int i = 0, l = itsInterfaces.length; i < l; i++) {
249
				ReferenceBinding inheritedInterface = itsInterfaces[i];
250
				if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
251
					if (interfacesToCheck.includes(inheritedInterface)) {
252
						TypeReference[] refs = this.type.scope.referenceContext.superInterfaces;
253
						for (int r = 0, rl = refs.length; r < rl; r++) {
254
							if (refs[r].resolvedType == inheritedInterface) {
255
								problemReporter().redundantSuperInterface(this.type, refs[r], inheritedInterface, superType);
256
								break;
257
							}
258
						}
259
					} else {
260
						inheritedInterfaces.add(inheritedInterface);
261
					}
262
				}
263
			}
264
		}
265
		superType = superType.superclass();
266
	}
267
268
	int nextPosition = inheritedInterfaces.elementSize;
269
	if (nextPosition == 0) return;
270
	ReferenceBinding[] interfacesToVisit = new ReferenceBinding[nextPosition];
271
	inheritedInterfaces.asArray(interfacesToVisit);
272
	for (int i = 0; i < nextPosition; i++) {
273
		superType = interfacesToVisit[i];
274
		if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
275
			int itsLength = itsInterfaces.length;
276
			if (nextPosition + itsLength >= interfacesToVisit.length)
277
				System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
278
			for (int a = 0; a < itsLength; a++) {
279
				ReferenceBinding inheritedInterface = itsInterfaces[a];
280
				if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
281
					if (interfacesToCheck.includes(inheritedInterface)) {
282
						TypeReference[] refs = this.type.scope.referenceContext.superInterfaces;
283
						for (int r = 0, rl = refs.length; r < rl; r++) {
284
							if (refs[r].resolvedType == inheritedInterface) {
285
								problemReporter().redundantSuperInterface(this.type, refs[r], inheritedInterface, superType);
286
								break;
287
							}
288
						}
289
					} else {
290
						inheritedInterfaces.add(inheritedInterface);
291
						interfacesToVisit[nextPosition++] = inheritedInterface;
292
					}
293
				}
294
			}
295
		}
296
	}
297
}
238
void checkInheritedMethods(MethodBinding[] methods, int length) {
298
void checkInheritedMethods(MethodBinding[] methods, int length) {
239
	if (length > 1) {
299
	if (length > 1) {
240
		int[] overriddenInheritedMethods = findOverriddenInheritedMethods(methods, length);
300
		int[] overriddenInheritedMethods = findOverriddenInheritedMethods(methods, length);
Lines 418-423 Link Here
418
		? this.type.scope.getJavaLangObject() // check interface methods against Object
478
		? this.type.scope.getJavaLangObject() // check interface methods against Object
419
		: this.type.superclass(); // class or enum
479
		: this.type.superclass(); // class or enum
420
	computeInheritedMethods(superclass, type.superInterfaces());
480
	computeInheritedMethods(superclass, type.superInterfaces());
481
	checkForRedundantSuperinterfaces(superclass, type.superInterfaces());
421
}
482
}
422
/*
483
/*
423
Binding creation is responsible for reporting:
484
Binding creation is responsible for reporting:
(-)src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java (+107 lines)
Lines 11-17 Link Here
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
13
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
14
15
16
import java.util.Map;
15
import junit.framework.Test;
17
import junit.framework.Test;
16
18
17
public class SuperTypeTest extends AbstractRegressionTest {
19
public class SuperTypeTest extends AbstractRegressionTest {
Lines 265-268 Link Here
265
		"----------\n"
267
		"----------\n"
266
	);
268
	);
267
}
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
			"class Y extends X implements I, J {}" + 
278
			"interface I {}\n" + 
279
			"interface J {}\n"
280
		},
281
		""
282
	);
283
}
284
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
285
// raising an error
286
public void test009() {
287
	Map customOptions = getCompilerOptions();
288
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface,  CompilerOptions.ERROR);
289
	this.runNegativeTest(
290
		new String[] {
291
			"X.java",
292
			"public class X implements I {}\n" + 
293
			"class Y extends X implements I, J {}\n" + 
294
			"interface I {}\n" + 
295
			"interface J {}\n"
296
		},
297
		"----------\n" + 
298
		"1. ERROR in X.java (at line 2)\n" + 
299
		"	class Y extends X implements I, J {}\n" + 
300
		"	                             ^\n" + 
301
		"Redundant superinterface I for the type Y, already defined by X\n" + 
302
		"----------\n",
303
		null /* no extra class libraries */, 
304
		true /* flush output directory */, 
305
		customOptions);
306
}
307
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
308
// raising an error - deeper hierarchy
309
public void test010() {
310
	Map customOptions = getCompilerOptions();
311
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
312
	this.runNegativeTest(
313
		new String[] {
314
			"X.java",
315
			"public class X implements I {}\n" + 
316
			"class Y extends X {}\n" + 
317
			"class Z extends Y implements J, I {}\n" + 
318
			"interface I {}\n" + 
319
			"interface J {}\n"
320
		},
321
		"----------\n" + 
322
		"1. ERROR in X.java (at line 3)\n" + 
323
		"	class Z extends Y implements J, I {}\n" + 
324
		"	                                ^\n" + 
325
		"Redundant superinterface I for the type Z, already defined by X\n" + 
326
		"----------\n",
327
		null /* no extra class libraries */, 
328
		true /* flush output directory */, 
329
		customOptions);
330
}
331
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
332
// no error - deeper hierarchy
333
public void test011() {
334
	Map customOptions = getCompilerOptions();
335
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface,  CompilerOptions.ERROR);
336
	this.runConformTest(
337
		new String[] {
338
			"X.java",
339
			"public class X implements I {}\n" + 
340
			"class Y extends X {}\n" + 
341
			"class Z extends Y implements J {}" + 
342
			"interface I {}\n" + 
343
			"interface J {}\n"
344
		},
345
		"",
346
		null /* no extra class libraries */, 
347
		true /* flush output directory */, 
348
		null /* no vm arguments */,
349
		customOptions,
350
		null /* no custom requestor*/);
351
}
352
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
353
// error - extending interfaces
354
public void test012() {
355
	Map customOptions = getCompilerOptions();
356
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface,  CompilerOptions.ERROR);
357
	this.runNegativeTest(
358
		new String[] {
359
			"X.java",
360
			"public class X implements J {}\n" + 
361
			"class Y extends X implements I {}\n" + 
362
			"interface I {}\n" + 
363
			"interface J extends I {}\n"
364
		},
365
		"----------\n" + 
366
		"1. ERROR in X.java (at line 2)\n" + 
367
		"	class Y extends X implements I {}\n" + 
368
		"	                             ^\n" + 
369
		"Redundant superinterface I for the type Y, already defined by J\n" + 
370
		"----------\n",
371
		null /* no extra class libraries */, 
372
		true /* flush output directory */, 
373
		customOptions);
374
}
268
}
375
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-1 / +2 lines)
Lines 37-43 Link Here
37
37
38
	static {
38
	static {
39
//	TESTS_NAMES = new String[] { "test000" };
39
//	TESTS_NAMES = new String[] { "test000" };
40
//	TESTS_NUMBERS = new int[] { 152 };
40
//	TESTS_NUMBERS = new int[] { 24 };
41
//	TESTS_RANGE = new int[] { 107, -1 };
41
//	TESTS_RANGE = new int[] { 107, -1 };
42
	}
42
	}
43
public BatchCompilerTest(String name) {
43
public BatchCompilerTest(String name) {
Lines 1273-1278 Link Here
1273
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" + 
1273
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" + 
1274
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" + 
1274
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" + 
1275
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" + 
1275
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" + 
1276
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" +
1276
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + 
1277
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + 
1277
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + 
1278
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + 
1278
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\n" + 
1279
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\n" + 
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+49 lines)
Lines 40593-40596 Link Here
40593
			"Unused type arguments for the non generic constructor Local() of type Local; it should not be parameterized with arguments <String>\n" + 
40593
			"Unused type arguments for the non generic constructor Local() of type Local; it should not be parameterized with arguments <String>\n" + 
40594
			"----------\n");
40594
			"----------\n");
40595
}	
40595
}	
40596
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
40597
// generic variants
40598
public void test1212() {
40599
	Map customOptions = getCompilerOptions();
40600
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface,  CompilerOptions.ERROR);
40601
	this.runNegativeTest(
40602
		new String[] {
40603
			"X.java",
40604
			"public class X<T> implements I<T> {}\n" + 
40605
			"class Y<T extends Z> extends X<T> implements I<T>, J {}\n" +
40606
			"class Z {}" + 
40607
			"interface I <T> {}\n" + 
40608
			"interface J {}\n"
40609
		},
40610
		"----------\n" + 
40611
		"1. ERROR in X.java (at line 2)\n" + 
40612
		"	class Y<T extends Z> extends X<T> implements I<T>, J {}\n" + 
40613
		"	                                             ^\n" + 
40614
		"Redundant superinterface I<T> for the type Y<T>, already defined by X<T>\n" + 
40615
		"----------\n",
40616
		null /* no extra class libraries */, 
40617
		true /* flush output directory */, 
40618
		customOptions);
40619
}
40620
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=77918
40621
// generic variants - the 'different arguments' error overrides the
40622
// redundant error
40623
public void test1213() {
40624
	Map customOptions = getCompilerOptions();
40625
	customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
40626
	this.runNegativeTest(
40627
		new String[] {
40628
			"X.java",
40629
			"public class X<T> implements I<T> {}\n" + 
40630
			"class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {}\n" +
40631
			"class Z {}" + 
40632
			"interface I <T> {}\n" + 
40633
			"interface J {}\n"
40634
		},
40635
		"----------\n" + 
40636
		"1. ERROR in X.java (at line 2)\n" + 
40637
		"	class Y<T extends Z, U extends T> extends X<T> implements I<U>, J {}\n" + 
40638
		"	      ^\n" + 
40639
		"The interface I cannot be implemented more than once with different arguments: I<T> and I<U>\n" + 
40640
		"----------\n",
40641
		null /* no extra class libraries */, 
40642
		true /* flush output directory */, 
40643
		customOptions);
40644
}
40596
}
40645
}

Return to bug 77918