View | Details | Raw Unified | Return to bug 322817 | Differences between
and this patch

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (+5 lines)
Lines 3530-3535 Link Here
3530
			} else if (token.equals("unusedTypeArgs")) { //$NON-NLS-1$
3530
			} else if (token.equals("unusedTypeArgs")) { //$NON-NLS-1$
3531
				setSeverity(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation, severity, isEnabling);
3531
				setSeverity(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation, severity, isEnabling);
3532
				return;
3532
				return;
3533
			} else if (token.equals("unavoidableGenericProblems")) { //$NON-NLS-1$
3534
				this.options.put(
3535
					CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems,
3536
					isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
3537
				return;
3533
			}
3538
			}
3534
			break;
3539
			break;
3535
		case 'v' :
3540
		case 'v' :
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+14 lines)
Lines 87-92 Link Here
87
	public static final String OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"; //$NON-NLS-1$
87
	public static final String OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"; //$NON-NLS-1$
88
	public static final String OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable"; //$NON-NLS-1$
88
	public static final String OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable"; //$NON-NLS-1$
89
	public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
89
	public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
90
	public static final String OPTION_ReportUnavoidableGenericTypeProblems = "org.eclipse.jdt.core.compiler.problem.UnavoidableGenericTypeProblems"; //$NON-NLS-1$
90
	public static final String OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$
91
	public static final String OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$
91
	public static final String OPTION_ReportRawTypeReference =  "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; //$NON-NLS-1$
92
	public static final String OPTION_ReportRawTypeReference =  "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; //$NON-NLS-1$
92
	public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
93
	public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
Lines 357-362 Link Here
357
	public boolean ignoreMethodBodies;
358
	public boolean ignoreMethodBodies;
358
	/** Raise null related warnings for variables tainted inside an assert statement (java 1.4 and above)*/
359
	/** Raise null related warnings for variables tainted inside an assert statement (java 1.4 and above)*/
359
	public boolean includeNullInfoFromAsserts;
360
	public boolean includeNullInfoFromAsserts;
361
	/** Controls whether unavoidable generic type problems get reported (FIXME) */
362
	public boolean reportUnavoidableGenericTypeProblems;
360
363
361
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
364
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
362
	public final static String[] warningTokens = {
365
	public final static String[] warningTokens = {
Lines 871-876 Link Here
871
		optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference, this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference ? ENABLED : DISABLED);
874
		optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference, this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference ? ENABLED : DISABLED);
872
		optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable, this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable ? ENABLED : DISABLED);
875
		optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable, this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable ? ENABLED : DISABLED);
873
		optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess));
876
		optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess));
877
		optionsMap.put(OPTION_ReportUnavoidableGenericTypeProblems, this.reportUnavoidableGenericTypeProblems ? ENABLED : DISABLED);
874
		optionsMap.put(OPTION_ReportUncheckedTypeOperation, getSeverityString(UncheckedTypeOperation));
878
		optionsMap.put(OPTION_ReportUncheckedTypeOperation, getSeverityString(UncheckedTypeOperation));
875
		optionsMap.put(OPTION_ReportRawTypeReference, getSeverityString(RawTypeReference));
879
		optionsMap.put(OPTION_ReportRawTypeReference, getSeverityString(RawTypeReference));
876
		optionsMap.put(OPTION_ReportFinalParameterBound, getSeverityString(FinalParameterBound));
880
		optionsMap.put(OPTION_ReportFinalParameterBound, getSeverityString(FinalParameterBound));
Lines 1012-1017 Link Here
1012
		// constructor/setter parameter hiding
1016
		// constructor/setter parameter hiding
1013
		this.reportSpecialParameterHidingField = false;
1017
		this.reportSpecialParameterHidingField = false;
1014
1018
1019
		this.reportUnavoidableGenericTypeProblems = true;
1020
1015
		// check javadoc comments tags
1021
		// check javadoc comments tags
1016
		this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
1022
		this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
1017
		this.reportInvalidJavadocTags = false;
1023
		this.reportInvalidJavadocTags = false;
Lines 1193-1198 Link Here
1193
				this.reportSpecialParameterHidingField = false;
1199
				this.reportSpecialParameterHidingField = false;
1194
			}
1200
			}
1195
		}
1201
		}
1202
		if ((optionValue = optionsMap.get(OPTION_ReportUnavoidableGenericTypeProblems)) != null) {
1203
			if (ENABLED.equals(optionValue)) {
1204
				this.reportUnavoidableGenericTypeProblems = true;
1205
			} else if (DISABLED.equals(optionValue)) {
1206
				this.reportUnavoidableGenericTypeProblems = false;
1207
			}
1208
		}
1196
		if ((optionValue = optionsMap.get(OPTION_ReportDeadCodeInTrivialIfStatement )) != null) {
1209
		if ((optionValue = optionsMap.get(OPTION_ReportDeadCodeInTrivialIfStatement )) != null) {
1197
			if (ENABLED.equals(optionValue)) {
1210
			if (ENABLED.equals(optionValue)) {
1198
				this.reportDeadCodeInTrivialIfStatement = true;
1211
				this.reportDeadCodeInTrivialIfStatement = true;
Lines 1516-1521 Link Here
1516
		buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
1529
		buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
1517
		buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
1530
		buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
1518
		buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
1531
		buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
1532
		buf.append("\n\t- report unavoidable generic type problems : ").append(this.reportUnavoidableGenericTypeProblems ? ENABLED : DISABLED); //$NON-NLS-1$
1519
		buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
1533
		buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
1520
		buf.append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); //$NON-NLS-1$
1534
		buf.append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); //$NON-NLS-1$
1521
		buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$
1535
		buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (+9 lines)
Lines 15-20 Link Here
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
17
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
18
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
18
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
19
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
19
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
20
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
20
21
Lines 158-163 Link Here
158
				if (reportIncompatibleReturnTypeError(currentMethod, inheritedMethod))
159
				if (reportIncompatibleReturnTypeError(currentMethod, inheritedMethod))
159
					continue nextMethod;
160
					continue nextMethod;
160
			}
161
			}
162
			
163
			if (options.sourceLevel >= ClassFileConstants.JDK1_5 
164
					&& !options.reportUnavoidableGenericTypeProblems
165
					&& options.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore)
166
				reportRawReferences(currentMethod, inheritedMethod);
161
167
162
			if (currentMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
168
			if (currentMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
163
				checkExceptions(currentMethod, inheritedMethod);
169
				checkExceptions(currentMethod, inheritedMethod);
Lines 185-190 Link Here
185
	}
191
	}
186
}
192
}
187
193
194
public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
195
	// nothing to do here. Real action happens at 1.5+
196
}
188
void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
197
void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
189
	// Remember that interfaces can only define public instance methods
198
	// Remember that interfaces can only define public instance methods
190
	if (concreteMethod.isStatic())
199
	if (concreteMethod.isStatic())
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (+59 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
14
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
16
import org.eclipse.jdt.internal.compiler.ast.Argument;
13
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
17
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
15
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
21
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
16
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
22
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
17
23
Lines 398-403 Link Here
398
404
399
	return false;
405
	return false;
400
}
406
}
407
408
void reportRawReferences() {
409
	CompilerOptions compilerOptions = this.type.scope.compilerOptions();
410
	if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
411
			|| compilerOptions.getSeverity(CompilerOptions.RawTypeReference) == ProblemSeverities.Ignore // ditto
412
			|| compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined 
413
		return;
414
	}
415
	/* Code below is only for a method that does not override/implement a super type method. If it were to,
416
	   it would have been handled in checkAgainstInheritedMethods.
417
	*/
418
	Object [] methodArray = this.currentMethods.valueTable;
419
	for (int s = methodArray.length; --s >= 0;) {
420
		if (methodArray[s] == null) continue;
421
		MethodBinding[] current = (MethodBinding[]) methodArray[s];
422
		for (int i = 0, length = current.length; i < length; i++) {
423
			MethodBinding currentMethod = current[i];
424
			if ((currentMethod.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) {
425
				AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
426
				if (methodDecl == null) return;
427
				TypeBinding [] parameterTypes = currentMethod.parameters;
428
				Argument[] arguments = methodDecl.arguments;
429
				for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
430
					TypeBinding parameterType = parameterTypes[j];
431
					Argument arg = arguments[j];
432
					if (parameterType.leafComponentType().isRawType()
433
			      		&& (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
434
						methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
435
			    	}
436
			    }
437
		    }
438
		}
439
	}
440
}
441
public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
442
	AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
443
	if (methodDecl == null) return;
444
	TypeBinding [] parameterTypes = currentMethod.parameters;
445
	TypeBinding [] inheritedParameterTypes = inheritedMethod.parameters;
446
	Argument[] arguments = methodDecl.arguments;
447
	for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
448
		TypeBinding parameterType = parameterTypes[j];
449
		TypeBinding inheritedParameterType = inheritedParameterTypes[j];
450
		Argument arg = arguments[j];
451
		if (parameterType.leafComponentType().isRawType() && !inheritedParameterType.leafComponentType().isRawType()
452
	      		&& (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
453
			methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
454
    	}
455
    }
456
}
457
401
void checkMethods() {
458
void checkMethods() {
402
	boolean mustImplementAbstractMethods = mustImplementAbstractMethods();
459
	boolean mustImplementAbstractMethods = mustImplementAbstractMethods();
403
	boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods
460
	boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods
Lines 903-908 Link Here
903
		this.type.detectAnnotationCycle();
960
		this.type.detectAnnotationCycle();
904
961
905
	super.verify();
962
	super.verify();
963
	
964
	reportRawReferences();
906
965
907
	for (int i = this.type.typeVariables.length; --i >= 0;) {
966
	for (int i = this.type.typeVariables.length; --i >= 0;) {
908
		TypeVariableBinding var = this.type.typeVariables[i];
967
		TypeVariableBinding var = this.type.typeVariables[i];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-1 / +13 lines)
Lines 1377-1383 Link Here
1377
			if (arg.annotations != null) {
1377
			if (arg.annotations != null) {
1378
				method.tagBits |= TagBits.HasParameterAnnotations;
1378
				method.tagBits |= TagBits.HasParameterAnnotations;
1379
			}
1379
			}
1380
			TypeBinding parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
1380
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
1381
			boolean deferRawTypeCheck = !this.scope.compilerOptions().reportUnavoidableGenericTypeProblems && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0;
1382
			TypeBinding parameterType;
1383
			if (deferRawTypeCheck)
1384
				arg.type.bits |= ASTNode.IgnoreRawTypeCheck;
1385
			try {
1386
				parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
1387
			} finally {
1388
				if (deferRawTypeCheck) { 
1389
					arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck;
1390
				}
1391
			}
1392
		
1381
			if (parameterType == null) {
1393
			if (parameterType == null) {
1382
				foundArgProblem = true;
1394
				foundArgProblem = true;
1383
			} else if (parameterType == TypeBinding.VOID) {
1395
			} else if (parameterType == TypeBinding.VOID) {
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java (+1 lines)
Lines 336-341 Link Here
336
			optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
336
			optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
337
			optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
337
			optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
338
			optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, CompilerOptions.DISABLED);
338
			optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, CompilerOptions.DISABLED);
339
			optionsMap.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED);
339
			optionsMap.put(CompilerOptions.OPTION_MaxProblemPerUnit, String.valueOf(100));
340
			optionsMap.put(CompilerOptions.OPTION_MaxProblemPerUnit, String.valueOf(100));
340
			optionsMap.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.DISABLED);
341
			optionsMap.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.DISABLED);
341
			this.defaultCompilerOptions = optionsMap;
342
			this.defaultCompilerOptions = optionsMap;
(-)model/org/eclipse/jdt/core/JavaCore.java (+14 lines)
Lines 900-905 Link Here
900
	 */
900
	 */
901
	public static final String COMPILER_PB_RAW_TYPE_REFERENCE = PLUGIN_ID + ".compiler.problem.rawTypeReference"; //$NON-NLS-1$
901
	public static final String COMPILER_PB_RAW_TYPE_REFERENCE = PLUGIN_ID + ".compiler.problem.rawTypeReference"; //$NON-NLS-1$
902
	/**
902
	/**
903
	 * Compiler option ID: Reporting of Unavoidable Generic Type Problems.
904
	 * <p> When enabled, the compiler will issue an error or warning even when it detects a generic type problem
905
	 *     that could not have been avoided by the programmer. (FIXME)
906
	 * <dl>
907
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems"</code></dd>
908
	 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
909
	 * <dt>Default:</dt><dd><code>"enabled"</code></dd>
910
	 * </dl>
911
	 * @since 3.7
912
	 * @category CompilerOptionID
913
	 */
914
	public static final String COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS = PLUGIN_ID + ".compiler.problem.unavoidableGenericTypeProblems"; //$NON-NLS-1$
915
916
	/**
903
	 * Compiler option ID: Reporting final Bound for Type Parameter.
917
	 * Compiler option ID: Reporting final Bound for Type Parameter.
904
	 * <p>When enabled, the compiler will issue an error or a warning whenever a generic type parameter is associated with a
918
	 * <p>When enabled, the compiler will issue an error or a warning whenever a generic type parameter is associated with a
905
	 *    bound corresponding to a final type; since final types cannot be further extended, the parameter is pretty useless.
919
	 *    bound corresponding to a final type; since final types cannot be further extended, the parameter is pretty useless.
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-1 / +71 lines)
Lines 1800-1806 Link Here
1800
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.sourceFile\" value=\"generate\"/>\n" + 
1800
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.sourceFile\" value=\"generate\"/>\n" + 
1801
			"		<option key=\"org.eclipse.jdt.core.compiler.doc.comment.support\" value=\"disabled\"/>\n" + 
1801
			"		<option key=\"org.eclipse.jdt.core.compiler.doc.comment.support\" value=\"disabled\"/>\n" + 
1802
			"		<option key=\"org.eclipse.jdt.core.compiler.generateClassFiles\" value=\"enabled\"/>\n" + 
1802
			"		<option key=\"org.eclipse.jdt.core.compiler.generateClassFiles\" value=\"enabled\"/>\n" + 
1803
			"		<option key=\"org.eclipse.jdt.core.compiler.maxProblemPerUnit\" value=\"100\"/>\n" + 
1803
			"		<option key=\"org.eclipse.jdt.core.compiler.maxProblemPerUnit\" value=\"100\"/>\n" +
1804
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.UnavoidableGenericTypeProblems\" value=\"enabled\"/>\n" +
1804
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\n" + 
1805
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\n" + 
1805
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\n" + 
1806
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\n" + 
1806
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.autoboxing\" value=\"ignore\"/>\n" + 
1807
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.autoboxing\" value=\"ignore\"/>\n" + 
Lines 12070-12073 Link Here
12070
		new File(lib1Path).delete();
12071
		new File(lib1Path).delete();
12071
	}
12072
	}
12072
}
12073
}
12074
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 -- with new option kicking in
12075
public void testReportingUnavoidableGenericProblems() {
12076
	this.runNegativeTest(
12077
		new String[] {
12078
			"X.java",
12079
			"interface Adaptable {\n" +
12080
			"    public Object getAdapter(Class clazz);    \n" +
12081
			"}\n" +
12082
			"public class X implements Adaptable {\n" +
12083
			"    public Object getAdapter(Class clazz) {\n" +
12084
			"        return null;\n" +
12085
			"    }\n" +
12086
			"    Zork z;\n" +
12087
			"}\n"
12088
		},
12089
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
12090
		+ " -1.5 -warn:-unavoidableGenericProblems -proc:none -d \"" + OUTPUT_DIR + "\"",
12091
		"",
12092
		"----------\n" + 
12093
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + 
12094
		"	public Object getAdapter(Class clazz);    \n" + 
12095
		"	                         ^^^^^\n" + 
12096
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
12097
		"----------\n" + 
12098
		"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 8)\n" + 
12099
		"	Zork z;\n" + 
12100
		"	^^^^\n" + 
12101
		"Zork cannot be resolved to a type\n" + 
12102
		"----------\n" + 
12103
		"2 problems (1 error, 1 warning)",
12104
		true);
12105
}
12106
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817  -- without new option kicking in
12107
public void testReportingUnavoidableGenericProblems2() {
12108
	this.runNegativeTest(
12109
		new String[] {
12110
			"X.java",
12111
			"interface Adaptable {\n" +
12112
			"    public Object getAdapter(Class clazz);    \n" +
12113
			"}\n" +
12114
			"public class X implements Adaptable {\n" +
12115
			"    public Object getAdapter(Class clazz) {\n" +
12116
			"        return null;\n" +
12117
			"    }\n" +
12118
			"    Zork z;\n" +
12119
			"}\n"
12120
		},
12121
		"\"" + OUTPUT_DIR +  File.separator + "X.java\""
12122
		+ " -1.5 -warn:+unavoidableGenericProblems -proc:none -d \"" + OUTPUT_DIR + "\"",
12123
		"",
12124
		"----------\n" + 
12125
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + 
12126
		"	public Object getAdapter(Class clazz);    \n" + 
12127
		"	                         ^^^^^\n" + 
12128
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
12129
		"----------\n" + 
12130
		"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + 
12131
		"	public Object getAdapter(Class clazz) {\n" + 
12132
		"	                         ^^^^^\n" + 
12133
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
12134
		"----------\n" + 
12135
		"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 8)\n" + 
12136
		"	Zork z;\n" + 
12137
		"	^^^^\n" + 
12138
		"Zork cannot be resolved to a type\n" + 
12139
		"----------\n" + 
12140
		"3 problems (1 error, 2 warnings)",
12141
		true);
12142
}
12073
}
12143
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java (+116 lines)
Lines 536-539 Link Here
536
            },
536
            },
537
            ""); // no specific success output string
537
            ""); // no specific success output string
538
}
538
}
539
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
540
public void test322817() {
541
	Map customOptions = getCompilerOptions();
542
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
543
	this.runNegativeTest(
544
			new String[] {
545
					"X.java",
546
					"interface Adaptable {\n" +
547
					"    public Object getAdapter(Class clazz);    \n" +
548
					"}\n" +
549
					"public class X implements Adaptable {\n" +
550
					"    public Object getAdapter(Class clazz) {\n" +
551
					"        return null;\n" +
552
					"    }\n" +
553
					"}\n"
554
			},
555
			"----------\n" + 
556
			"1. WARNING in X.java (at line 2)\n" + 
557
			"	public Object getAdapter(Class clazz);    \n" + 
558
			"	                         ^^^^^\n" + 
559
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
560
			"----------\n",
561
			null,
562
			true,
563
			customOptions);
564
}
565
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
566
public void test322817b() {
567
	Map customOptions = getCompilerOptions();
568
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED);
569
	this.runNegativeTest(
570
			new String[] {
571
					"X.java",
572
					"interface Adaptable {\n" +
573
					"    public Object getAdapter(Class clazz);    \n" +
574
					"}\n" +
575
					"public class X implements Adaptable {\n" +
576
					"    public Object getAdapter(Class clazz) {\n" +
577
					"        return null;\n" +
578
					"    }\n" +
579
					"}\n"
580
			},
581
			"----------\n" + 
582
			"1. WARNING in X.java (at line 2)\n" + 
583
			"	public Object getAdapter(Class clazz);    \n" + 
584
			"	                         ^^^^^\n" + 
585
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
586
			"----------\n" + 
587
			"2. WARNING in X.java (at line 5)\n" + 
588
			"	public Object getAdapter(Class clazz) {\n" + 
589
			"	                         ^^^^^\n" + 
590
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
591
			"----------\n",
592
			null,
593
			true,
594
			customOptions);
595
}
596
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
597
public void test322817c() {
598
	Map customOptions = getCompilerOptions();
599
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
600
	this.runNegativeTest(
601
			new String[] {
602
					"X.java",
603
					"interface Adaptable {\n" +
604
					"    public Object getAdapter(Class<String> clazz);    \n" +
605
					"}\n" +
606
					"public class X implements Adaptable {\n" +
607
					"    public Object getAdapter(Class clazz) {\n" +
608
					"        return null;\n" +
609
					"    }\n" +
610
					"}\n"
611
			},
612
			"----------\n" + 
613
			"1. WARNING in X.java (at line 5)\n" + 
614
			"	public Object getAdapter(Class clazz) {\n" + 
615
			"	                         ^^^^^\n" + 
616
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
617
			"----------\n",
618
			null,
619
			true,
620
			customOptions);
621
}
622
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
623
public void test322817d() {
624
	Map customOptions = getCompilerOptions();
625
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
626
	this.runNegativeTest(
627
			new String[] {
628
					"X.java",
629
					"interface Adaptable {\n" +
630
					"    public Object getAdapter(Class<String> clazz);    \n" +
631
					"}\n" +
632
					"public class X implements Adaptable {\n" +
633
					"    public Object getAdapter(Class clazz) {\n" +
634
					"        return null;\n" +
635
					"    }\n" +
636
					"}\n" +
637
					"class Y extends X {\n" +
638
					"    @Override\n" +
639
					"    public Object getAdapter(Class clazz) {\n" +
640
					"        return null;\n" +
641
					"    }\n" +
642
					"}\n"
643
644
			},
645
			"----------\n" + 
646
			"1. WARNING in X.java (at line 5)\n" + 
647
			"	public Object getAdapter(Class clazz) {\n" + 
648
			"	                         ^^^^^\n" + 
649
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
650
			"----------\n",
651
			null,
652
			true,
653
			customOptions);
654
}
539
}
655
}

Return to bug 322817