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/ast/ASTNode.java (-1 / +3 lines)
Lines 343-349 Link Here
343
		if ((invocationStatus & INVOCATION_ARGUMENT_WILDCARD) != 0) {
343
		if ((invocationStatus & INVOCATION_ARGUMENT_WILDCARD) != 0) {
344
		    scope.problemReporter().wildcardInvocation((ASTNode)invocationSite, receiverType, method, argumentTypes);
344
		    scope.problemReporter().wildcardInvocation((ASTNode)invocationSite, receiverType, method, argumentTypes);
345
		} else if (!method.isStatic() && !receiverType.isUnboundWildcard() && method.declaringClass.isRawType() && method.hasSubstitutedParameters()) {
345
		} else if (!method.isStatic() && !receiverType.isUnboundWildcard() && method.declaringClass.isRawType() && method.hasSubstitutedParameters()) {
346
		    scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method);
346
			if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || receiver == null || !receiver.forcedToBeRaw(scope.referenceContext())) {
347
				scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method);
348
			}
347
		} else if (rawOriginalGenericMethod != null 
349
		} else if (rawOriginalGenericMethod != null 
348
				|| uncheckedBoundCheck
350
				|| uncheckedBoundCheck
349
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
351
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java (-1 / +3 lines)
Lines 494-500 Link Here
494
				if (isLegal) {
494
				if (isLegal) {
495
					this.expression.computeConversion(scope, castType, expressionType);
495
					this.expression.computeConversion(scope, castType, expressionType);
496
					if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast
496
					if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast
497
						scope.problemReporter().unsafeCast(this, scope);
497
						if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || !this.expression.forcedToBeRaw(scope.referenceContext())) {
498
							scope.problemReporter().unsafeCast(this, scope);
499
						}
498
					} else {
500
					} else {
499
						if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
501
						if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
500
							scope.problemReporter().rawTypeReference(this.type, castType);
502
							scope.problemReporter().rawTypeReference(this.type, castType);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java (+25 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
21
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
22
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
22
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
24
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
24
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.Binding;
27
import org.eclipse.jdt.internal.compiler.lookup.Binding;
Lines 958-963 Link Here
958
	}
959
	}
959
	return expressionType;
960
	return expressionType;
960
}
961
}
962
/**
963
 * Returns true if the receiver is forced to be of raw type either to satisfy the contract imposed
964
 * by a super type or because it *is* raw and the current type has no control over it (i.e the rawness
965
 * originates from some other file.
966
 */
967
public boolean forcedToBeRaw(ReferenceContext referenceContext) {
968
	if (this instanceof NameReference) {
969
		final Binding receiverBinding = ((NameReference) this).binding;
970
		if (receiverBinding.isParameter() && (((LocalVariableBinding) receiverBinding).tagBits & TagBits.ForcedToBeRawType) != 0) {
971
			return true;  // parameter is forced to be raw since super method uses raw types.
972
		}
973
	} else if (this instanceof MessageSend) {
974
		if (!CharOperation.equals(((MessageSend) this).binding.declaringClass.getFileName(),
975
				referenceContext.compilationResult().getFileName())) {  // problem is rooted elsewhere
976
			return true;
977
		}
978
	} else if (this instanceof FieldReference) {
979
		if (!CharOperation.equals(((FieldReference) this).binding.declaringClass.getFileName(),
980
				referenceContext.compilationResult().getFileName())) { // problem is rooted elsewhere
981
			return true;
982
		}
983
	}
984
	return false;
985
}
961
986
962
/**
987
/**
963
 * Returns an object which can be used to identify identical JSR sequence targets
988
 * Returns an object which can be used to identify identical JSR sequence targets
(-)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 forced generic type problems get reported  */
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/Binding.java (+3 lines)
Lines 94-99 Link Here
94
	public boolean isVolatile() {
94
	public boolean isVolatile() {
95
		return false;
95
		return false;
96
	}
96
	}
97
	public boolean isParameter() {
98
		return false;
99
	}
97
	/* API
100
	/* API
98
	* Answer the problem id associated with the receiver.
101
	* Answer the problem id associated with the receiver.
99
	* NoError if the receiver is a valid binding.
102
	* NoError if the receiver is a valid binding.
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java (+5 lines)
Lines 41-46 Link Here
41
	public LocalVariableBinding(char[] name, TypeBinding type, int modifiers, boolean isArgument) {
41
	public LocalVariableBinding(char[] name, TypeBinding type, int modifiers, boolean isArgument) {
42
		super(name, type, modifiers, isArgument ? Constant.NotAConstant : null);
42
		super(name, type, modifiers, isArgument ? Constant.NotAConstant : null);
43
		if (isArgument) this.tagBits |= TagBits.IsArgument;
43
		if (isArgument) this.tagBits |= TagBits.IsArgument;
44
		this.tagBits &= ~TagBits.ForcedToBeRawType;
44
	}
45
	}
45
46
46
	// regular local variable or argument
47
	// regular local variable or argument
Lines 244-247 Link Here
244
		}
245
		}
245
		return s;
246
		return s;
246
	}
247
	}
248
249
	public boolean isParameter() {
250
		return ((this.tagBits & TagBits.IsArgument) != 0);
251
	}
247
}
252
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (-1 / +4 lines)
Lines 158-164 Link Here
158
				if (reportIncompatibleReturnTypeError(currentMethod, inheritedMethod))
158
				if (reportIncompatibleReturnTypeError(currentMethod, inheritedMethod))
159
					continue nextMethod;
159
					continue nextMethod;
160
			}
160
			}
161
161
			reportRawReferences(currentMethod, inheritedMethod); // if they were deferred, emit them now.
162
			if (currentMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
162
			if (currentMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
163
				checkExceptions(currentMethod, inheritedMethod);
163
				checkExceptions(currentMethod, inheritedMethod);
164
			if (inheritedMethod.isFinal())
164
			if (inheritedMethod.isFinal())
Lines 185-190 Link Here
185
	}
185
	}
186
}
186
}
187
187
188
public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
189
	// nothing to do here. Real action happens at 1.5+
190
}
188
void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
191
void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
189
	// Remember that interfaces can only define public instance methods
192
	// Remember that interfaces can only define public instance methods
190
	if (concreteMethod.isStatic())
193
	if (concreteMethod.isStatic())
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (+98 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;
17
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
13
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
18
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
19
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
15
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
23
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
16
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
24
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
17
25
Lines 398-403 Link Here
398
406
399
	return false;
407
	return false;
400
}
408
}
409
410
void reportRawReferences() {
411
	CompilerOptions compilerOptions = this.type.scope.compilerOptions();
412
	if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
413
			|| compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined 
414
		return;
415
	}
416
	/* Code below is only for a method that does not override/implement a super type method. If it were to,
417
	   it would have been handled in checkAgainstInheritedMethods.
418
	*/
419
	Object [] methodArray = this.currentMethods.valueTable;
420
	for (int s = methodArray.length; --s >= 0;) {
421
		if (methodArray[s] == null) continue;
422
		MethodBinding[] current = (MethodBinding[]) methodArray[s];
423
		for (int i = 0, length = current.length; i < length; i++) {
424
			MethodBinding currentMethod = current[i];
425
			if ((currentMethod.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) {
426
				AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
427
				if (methodDecl == null) return;
428
				TypeBinding [] parameterTypes = currentMethod.parameters;
429
				Argument[] arguments = methodDecl.arguments;
430
				for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
431
					TypeBinding parameterType = parameterTypes[j];
432
					Argument arg = arguments[j];
433
					if (parameterType.leafComponentType().isRawType()
434
						&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
435
			      		&& (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
436
						methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
437
			    	}
438
				}
439
				if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration) {
440
					TypeReference returnType = ((MethodDeclaration) methodDecl).returnType;
441
					TypeBinding methodType = currentMethod.returnType;
442
					if (returnType != null) {
443
						if (methodType.leafComponentType().isRawType()
444
								&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
445
								&& (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
446
							methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
447
						}
448
					}
449
				}
450
			}
451
		}
452
	}
453
}
454
public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
455
	CompilerOptions compilerOptions = this.type.scope.compilerOptions();
456
	if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
457
			|| compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined 
458
		return;
459
	}
460
	AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
461
	if (methodDecl == null) return;
462
	TypeBinding [] parameterTypes = currentMethod.parameters;
463
	TypeBinding [] inheritedParameterTypes = inheritedMethod.parameters;
464
	Argument[] arguments = methodDecl.arguments;
465
	for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
466
		TypeBinding parameterType = parameterTypes[j];
467
		TypeBinding inheritedParameterType = inheritedParameterTypes[j];
468
		Argument arg = arguments[j];
469
		if (parameterType.leafComponentType().isRawType()) {
470
			if (inheritedParameterType.leafComponentType().isRawType()) {
471
				arg.binding.tagBits |= TagBits.ForcedToBeRawType;
472
			} else {
473
				if (compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
474
						&& (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
475
					methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
476
				}
477
			}
478
    	}
479
    }
480
	TypeReference returnType = null;
481
	if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration && (returnType = ((MethodDeclaration) methodDecl).returnType) != null) {
482
		final TypeBinding inheritedMethodType = inheritedMethod.returnType;
483
		final TypeBinding methodType = currentMethod.returnType;
484
		if (methodType.leafComponentType().isRawType()) {
485
			if (inheritedMethodType.leafComponentType().isRawType()) {
486
				// 
487
			} else {
488
				if ((returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0
489
						&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
490
					methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
491
				}
492
			}
493
		}
494
	}
495
 }
496
401
void checkMethods() {
497
void checkMethods() {
402
	boolean mustImplementAbstractMethods = mustImplementAbstractMethods();
498
	boolean mustImplementAbstractMethods = mustImplementAbstractMethods();
403
	boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods
499
	boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods
Lines 903-908 Link Here
903
		this.type.detectAnnotationCycle();
999
		this.type.detectAnnotationCycle();
904
1000
905
	super.verify();
1001
	super.verify();
1002
	
1003
	reportRawReferences();
906
1004
907
	for (int i = this.type.typeVariables.length; --i >= 0;) {
1005
	for (int i = this.type.typeVariables.length; --i >= 0;) {
908
		TypeVariableBinding var = this.type.typeVariables[i];
1006
		TypeVariableBinding var = this.type.typeVariables[i];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-3 / +28 lines)
Lines 1365-1371 Link Here
1365
		if (count < size)
1365
		if (count < size)
1366
			System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count], 0, count);
1366
			System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count], 0, count);
1367
	}
1367
	}
1368
1368
	final boolean reportUnavoidableGenericTypeProblems = this.scope.compilerOptions().reportUnavoidableGenericTypeProblems;
1369
	boolean foundArgProblem = false;
1369
	boolean foundArgProblem = false;
1370
	Argument[] arguments = methodDecl.arguments;
1370
	Argument[] arguments = methodDecl.arguments;
1371
	if (arguments != null) {
1371
	if (arguments != null) {
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 = !reportUnavoidableGenericTypeProblems && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0;
1382
			TypeBinding parameterType;
1383
			if (deferRawTypeCheck) {
1384
				arg.type.bits |= ASTNode.IgnoreRawTypeCheck;
1385
			}
1386
			try {
1387
				parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
1388
			} finally {
1389
				if (deferRawTypeCheck) { 
1390
					arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck;
1391
				}
1392
			}
1393
		
1381
			if (parameterType == null) {
1394
			if (parameterType == null) {
1382
				foundArgProblem = true;
1395
				foundArgProblem = true;
1383
			} else if (parameterType == TypeBinding.VOID) {
1396
			} else if (parameterType == TypeBinding.VOID) {
Lines 1410-1416 Link Here
1410
			method.returnType = null;
1423
			method.returnType = null;
1411
			foundReturnTypeProblem = true;
1424
			foundReturnTypeProblem = true;
1412
		} else {
1425
		} else {
1413
			TypeBinding methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/);
1426
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
1427
			boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0;
1428
			TypeBinding methodType;
1429
			if (deferRawTypeCheck) {
1430
				returnType.bits |= ASTNode.IgnoreRawTypeCheck;
1431
			}
1432
			try {
1433
				methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/);
1434
			} finally {
1435
				if (deferRawTypeCheck) { 
1436
					returnType.bits &= ~ASTNode.IgnoreRawTypeCheck;
1437
				}
1438
			}
1414
			if (methodType == null) {
1439
			if (methodType == null) {
1415
				foundReturnTypeProblem = true;
1440
				foundReturnTypeProblem = true;
1416
			} else if (methodType.isArrayType() && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) {
1441
			} else if (methodType.isArrayType() && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java (+3 lines)
Lines 35-40 Link Here
35
	
35
	
36
	// local variable
36
	// local variable
37
	long NotInitialized = ASTNode.Bit9;
37
	long NotInitialized = ASTNode.Bit9;
38
	
39
	// local variable
40
	long ForcedToBeRawType = ASTNode.Bit10;
38
41
39
	// set when method has argument(s) that couldn't be resolved
42
	// set when method has argument(s) that couldn't be resolved
40
	long HasUnresolvedArguments = ASTNode.Bit10;
43
	long HasUnresolvedArguments = ASTNode.Bit10;
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+3 lines)
Lines 7130-7135 Link Here
7130
	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
7130
	if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259
7131
	int severity = computeSeverity(IProblem.UnsafeTypeConversion);
7131
	int severity = computeSeverity(IProblem.UnsafeTypeConversion);
7132
	if (severity == ProblemSeverities.Ignore) return;
7132
	if (severity == ProblemSeverities.Ignore) return;
7133
	if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) {
7134
		return;
7135
	}
7133
	this.handle(
7136
	this.handle(
7134
		IProblem.UnsafeTypeConversion,
7137
		IProblem.UnsafeTypeConversion,
7135
		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
7138
		new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) },
(-)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 (+16 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. As an example, a type may be forced to use raw types
906
	 *     in its method signatures and return types because the methods it overrides from a super type are declared to
907
	 *     use raw types in the first place.  
908
	 * <dl>
909
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems"</code></dd>
910
	 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
911
	 * <dt>Default:</dt><dd><code>"enabled"</code></dd>
912
	 * </dl>
913
	 * @since 3.7
914
	 * @category CompilerOptionID
915
	 */
916
	public static final String COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS = PLUGIN_ID + ".compiler.problem.unavoidableGenericTypeProblems"; //$NON-NLS-1$
917
918
	/**
903
	 * Compiler option ID: Reporting final Bound for Type Parameter.
919
	 * 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
920
	 * <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.
921
	 *    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.annotationSuperInterface\" value=\"warning\"/>\n" + 
1804
			"		<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" + 
1805
			"		<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" + 
1806
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.autoboxing\" value=\"ignore\"/>\n" + 
Lines 1864-1869 Link Here
1864
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\n" + 
1864
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\n" + 
1865
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.tasks\" value=\"warning\"/>\n" + 
1865
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.tasks\" value=\"warning\"/>\n" + 
1866
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.typeParameterHiding\" value=\"warning\"/>\n" + 
1866
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.typeParameterHiding\" value=\"warning\"/>\n" + 
1867
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems\" value=\"enabled\"/>\n" +
1867
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation\" value=\"warning\"/>\n" + 
1868
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation\" value=\"warning\"/>\n" + 
1868
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock\" value=\"ignore\"/>\n" + 
1869
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock\" value=\"ignore\"/>\n" + 
1869
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unhandledWarningToken\" value=\"warning\"/>\n" + 
1870
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unhandledWarningToken\" value=\"warning\"/>\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 (+621 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
}
655
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
656
public void test322817e() {
657
	Map customOptions = getCompilerOptions();
658
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
659
	this.runNegativeTest(
660
			new String[] {
661
					"X.java",
662
					"import java.util.List;\n" +
663
					"class Top {\n" +
664
					"    public void set(List arg) { } // OK to warn in 1.5 code\n" +
665
					"    public List get() { return null; } // OK to warn in 1.5 code\n" +
666
					"}\n" +
667
					"class Sub extends Top {\n" +
668
					"    @Override\n" +
669
					"    public void set(List arg) { // should not warn (overrides)\n" +
670
					"    }\n" +
671
					"    @Override\n" +
672
					"    public List get() { // should not warn (overrides)\n" +
673
					"        return super.get();\n" +
674
					"    }\n" +
675
					"}\n" +
676
					"public class X {\n" +
677
					"}\n"
678
			},
679
			"----------\n" + 
680
			"1. WARNING in X.java (at line 3)\n" + 
681
			"	public void set(List arg) { } // OK to warn in 1.5 code\n" + 
682
			"	                ^^^^\n" + 
683
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
684
			"----------\n" + 
685
			"2. WARNING in X.java (at line 4)\n" + 
686
			"	public List get() { return null; } // OK to warn in 1.5 code\n" + 
687
			"	       ^^^^\n" + 
688
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
689
			"----------\n",
690
			null,
691
			true,
692
			customOptions);
693
}
694
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817
695
public void test322817f() {
696
	Map customOptions = getCompilerOptions();
697
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
698
	this.runNegativeTest(
699
			new String[] {
700
					"X.java",
701
					"import java.util.List;\n" +
702
					"class Top {\n" +
703
					"    public void set(List arg) { } // OK to warn in 1.5 code\n" +
704
					"    public List<String> get() { return null; }\n" +
705
					"}\n" +
706
					"class Sub extends Top {\n" +
707
					"    @Override\n" +
708
					"    public void set(List arg) { // should not warn (overrides)\n" +
709
					"    }\n" +
710
					"    @Override\n" +
711
					"    public List get() { // should warn (super's return type is not raw)\n" +
712
					"        return super.get();\n" +
713
					"    }\n" +
714
					"}\n" +
715
					"public class X {\n" +
716
					"}\n"
717
			},
718
			"----------\n" + 
719
			"1. WARNING in X.java (at line 3)\n" + 
720
			"	public void set(List arg) { } // OK to warn in 1.5 code\n" + 
721
			"	                ^^^^\n" + 
722
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
723
			"----------\n" + 
724
			"2. WARNING in X.java (at line 11)\n" + 
725
			"	public List get() { // should warn (super\'s return type is not raw)\n" + 
726
			"	       ^^^^\n" + 
727
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
728
			"----------\n" + 
729
			"3. WARNING in X.java (at line 11)\n" + 
730
			"	public List get() { // should warn (super\'s return type is not raw)\n" + 
731
			"	       ^^^^\n" + 
732
			"Type safety: The return type List for get() from the type Sub needs unchecked conversion to conform to List<String> from the type Top\n" + 
733
			"----------\n",
734
			null,
735
			true,
736
			customOptions);
737
}
738
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 (Disable reporting of unavoidable problems)
739
public void test322817g() {
740
	Map customOptions = getCompilerOptions();
741
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
742
	this.runNegativeTest(
743
			new String[] {
744
					"Top.java",
745
					"import java.util.List;\n" +
746
					"public class Top {\n" +
747
					"    public void set(List arg) { } // OK to warn in 1.5 code\n" +
748
					"    public List get() { return null; } // OK to warn in 1.5 code\n" +
749
					"    List list; // OK to warn in 1.5 code\n" +
750
					"}\n",
751
					"Sub.java",
752
					"import java.util.List;\n" +
753
					"public class Sub extends Top {\n" +
754
					"    @Override\n" +
755
					"    public void set(List arg) { // should not warn (overrides)\n" +
756
					"        super.set(arg);\n" +
757
					"        arg.set(0, \"A\"); // should not warn ('arg' is forced raw)\n" +
758
					"    }\n" +
759
					"    @Override\n" +
760
					"    public List get() { // should not warn (overrides)\n" +
761
					"        return super.get();\n" +
762
					"    }\n" +
763
					"}\n",
764
					"X.java",
765
					"import java.util.List;\n" +
766
					"public class X {\n" +
767
					"    void run() {\n" +
768
					"        new Top().list.add(\"arg\"); // should not warn (uses raw field declared elsewhere)\n" +
769
					"        new Top().get().add(\"arg\"); // should not warn (uses raw API)\n" +
770
					"        List raw= new Top().get(); // OK to warn ('raw' declared here)\n" +
771
					"        raw.add(\"arg\"); // OK to warn ('raw' declared here)\n" +
772
					"        // When Top#get() is generified, both of the following will fail\n" +
773
					"        // with a compile error if type arguments don't match:\n" +
774
					"        List<String> unchecked= new Top().get(); // should not warn (forced)\n" +
775
					"        unchecked.add(\"x\");\n" +
776
					"        // Should not warn about unchecked cast, but should warn about\n" +
777
					"        // unnecessary cast:\n" +
778
					"        List<String> cast= (List<String>) new Top().get();\n" +
779
					"        cast.add(\"x\");\n" +
780
					"    }\n" +
781
					"}\n"
782
			},
783
			"----------\n" + 
784
			"1. WARNING in Top.java (at line 3)\n" + 
785
			"	public void set(List arg) { } // OK to warn in 1.5 code\n" + 
786
			"	                ^^^^\n" + 
787
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
788
			"----------\n" + 
789
			"2. WARNING in Top.java (at line 4)\n" + 
790
			"	public List get() { return null; } // OK to warn in 1.5 code\n" + 
791
			"	       ^^^^\n" + 
792
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
793
			"----------\n" + 
794
			"3. WARNING in Top.java (at line 5)\n" + 
795
			"	List list; // OK to warn in 1.5 code\n" + 
796
			"	^^^^\n" + 
797
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
798
			"----------\n" + 
799
			"----------\n" + 
800
			"1. WARNING in X.java (at line 6)\n" + 
801
			"	List raw= new Top().get(); // OK to warn (\'raw\' declared here)\n" + 
802
			"	^^^^\n" + 
803
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
804
			"----------\n" + 
805
			"2. WARNING in X.java (at line 7)\n" + 
806
			"	raw.add(\"arg\"); // OK to warn (\'raw\' declared here)\n" + 
807
			"	^^^^^^^^^^^^^^\n" + 
808
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
809
			"----------\n" + 
810
			"3. WARNING in X.java (at line 14)\n" + 
811
			"	List<String> cast= (List<String>) new Top().get();\n" + 
812
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
813
			"Unnecessary cast from List to List<String>\n" + 
814
			"----------\n",
815
			null,
816
			true,
817
			customOptions);
818
}
819
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 (Enable reporting of unavoidable problems)
820
public void test322817h() {
821
	Map customOptions = getCompilerOptions();
822
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED);
823
	this.runNegativeTest(
824
			new String[] {
825
					"Top.java",
826
					"import java.util.List;\n" +
827
					"public class Top {\n" +
828
					"    public void set(List arg) { }\n" +
829
					"    public List get() { return null; }\n" +
830
					"    List list;\n" +
831
					"}\n",
832
					"Sub.java",
833
					"import java.util.List;\n" +
834
					"public class Sub extends Top {\n" +
835
					"    @Override\n" +
836
					"    public void set(List arg) {\n" +
837
					"        super.set(arg);\n" +
838
					"        arg.set(0, \"A\");\n" +
839
					"    }\n" +
840
					"    @Override\n" +
841
					"    public List get() {\n" +
842
					"        return super.get();\n" +
843
					"    }\n" +
844
					"}\n",
845
					"X.java",
846
					"import java.util.List;\n" +
847
					"public class X {\n" +
848
					"    void run() {\n" +
849
					"        new Top().list.add(\"arg\");\n" +
850
					"        new Top().get().add(\"arg\");\n" +
851
					"        List raw= new Top().get();\n" +
852
					"        raw.add(\"arg\");\n" +
853
					"        List<String> unchecked= new Top().get();\n" +
854
					"        unchecked.add(\"x\");\n" +
855
					"        List<String> cast= (List<String>) new Top().get();\n" +
856
					"        cast.add(\"x\");\n" +
857
					"    }\n" +
858
					"}\n"
859
			},
860
			"----------\n" + 
861
			"1. WARNING in Top.java (at line 3)\n" + 
862
			"	public void set(List arg) { }\n" + 
863
			"	                ^^^^\n" + 
864
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
865
			"----------\n" + 
866
			"2. WARNING in Top.java (at line 4)\n" + 
867
			"	public List get() { return null; }\n" + 
868
			"	       ^^^^\n" + 
869
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
870
			"----------\n" + 
871
			"3. WARNING in Top.java (at line 5)\n" + 
872
			"	List list;\n" + 
873
			"	^^^^\n" + 
874
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
875
			"----------\n" + 
876
			"----------\n" + 
877
			"1. WARNING in Sub.java (at line 4)\n" + 
878
			"	public void set(List arg) {\n" + 
879
			"	                ^^^^\n" + 
880
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
881
			"----------\n" + 
882
			"2. WARNING in Sub.java (at line 6)\n" + 
883
			"	arg.set(0, \"A\");\n" + 
884
			"	^^^^^^^^^^^^^^^\n" + 
885
			"Type safety: The method set(int, Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
886
			"----------\n" + 
887
			"3. WARNING in Sub.java (at line 9)\n" + 
888
			"	public List get() {\n" + 
889
			"	       ^^^^\n" + 
890
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
891
			"----------\n" + 
892
			"----------\n" + 
893
			"1. WARNING in X.java (at line 4)\n" + 
894
			"	new Top().list.add(\"arg\");\n" + 
895
			"	^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
896
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
897
			"----------\n" + 
898
			"2. WARNING in X.java (at line 5)\n" + 
899
			"	new Top().get().add(\"arg\");\n" + 
900
			"	^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
901
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
902
			"----------\n" + 
903
			"3. WARNING in X.java (at line 6)\n" + 
904
			"	List raw= new Top().get();\n" + 
905
			"	^^^^\n" + 
906
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
907
			"----------\n" + 
908
			"4. WARNING in X.java (at line 7)\n" + 
909
			"	raw.add(\"arg\");\n" + 
910
			"	^^^^^^^^^^^^^^\n" + 
911
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
912
			"----------\n" + 
913
			"5. WARNING in X.java (at line 8)\n" + 
914
			"	List<String> unchecked= new Top().get();\n" + 
915
			"	                        ^^^^^^^^^^^^^^^\n" + 
916
			"Type safety: The expression of type List needs unchecked conversion to conform to List<String>\n" + 
917
			"----------\n" + 
918
			"6. WARNING in X.java (at line 10)\n" + 
919
			"	List<String> cast= (List<String>) new Top().get();\n" + 
920
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
921
			"Type safety: Unchecked cast from List to List<String>\n" + 
922
			"----------\n" + 
923
			"7. WARNING in X.java (at line 10)\n" + 
924
			"	List<String> cast= (List<String>) new Top().get();\n" + 
925
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
926
			"Unnecessary cast from List to List<String>\n" + 
927
			"----------\n",
928
			null,
929
			true,
930
			customOptions);
931
}
932
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 (Default options)
933
public void test322817i() {
934
	Map customOptions = getCompilerOptions();
935
	this.runNegativeTest(
936
			new String[] {
937
					"Top.java",
938
					"import java.util.List;\n" +
939
					"public class Top {\n" +
940
					"    public void set(List arg) { }\n" +
941
					"    public List get() { return null; }\n" +
942
					"    List list;\n" +
943
					"}\n",
944
					"Sub.java",
945
					"import java.util.List;\n" +
946
					"public class Sub extends Top {\n" +
947
					"    @Override\n" +
948
					"    public void set(List arg) {\n" +
949
					"        super.set(arg);\n" +
950
					"        arg.set(0, \"A\");\n" +
951
					"    }\n" +
952
					"    @Override\n" +
953
					"    public List get() {\n" +
954
					"        return super.get();\n" +
955
					"    }\n" +
956
					"}\n",
957
					"X.java",
958
					"import java.util.List;\n" +
959
					"public class X {\n" +
960
					"    void run() {\n" +
961
					"        new Top().list.add(\"arg\");\n" +
962
					"        new Top().get().add(\"arg\");\n" +
963
					"        List raw= new Top().get();\n" +
964
					"        raw.add(\"arg\");\n" +
965
					"        List<String> unchecked= new Top().get();\n" +
966
					"        unchecked.add(\"x\");\n" +
967
					"        List<String> cast= (List<String>) new Top().get();\n" +
968
					"        cast.add(\"x\");\n" +
969
					"    }\n" +
970
					"}\n"
971
			},
972
			"----------\n" + 
973
			"1. WARNING in Top.java (at line 3)\n" + 
974
			"	public void set(List arg) { }\n" + 
975
			"	                ^^^^\n" + 
976
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
977
			"----------\n" + 
978
			"2. WARNING in Top.java (at line 4)\n" + 
979
			"	public List get() { return null; }\n" + 
980
			"	       ^^^^\n" + 
981
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
982
			"----------\n" + 
983
			"3. WARNING in Top.java (at line 5)\n" + 
984
			"	List list;\n" + 
985
			"	^^^^\n" + 
986
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
987
			"----------\n" + 
988
			"----------\n" + 
989
			"1. WARNING in Sub.java (at line 4)\n" + 
990
			"	public void set(List arg) {\n" + 
991
			"	                ^^^^\n" + 
992
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
993
			"----------\n" + 
994
			"2. WARNING in Sub.java (at line 6)\n" + 
995
			"	arg.set(0, \"A\");\n" + 
996
			"	^^^^^^^^^^^^^^^\n" + 
997
			"Type safety: The method set(int, Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
998
			"----------\n" + 
999
			"3. WARNING in Sub.java (at line 9)\n" + 
1000
			"	public List get() {\n" + 
1001
			"	       ^^^^\n" + 
1002
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
1003
			"----------\n" + 
1004
			"----------\n" + 
1005
			"1. WARNING in X.java (at line 4)\n" + 
1006
			"	new Top().list.add(\"arg\");\n" + 
1007
			"	^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1008
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
1009
			"----------\n" + 
1010
			"2. WARNING in X.java (at line 5)\n" + 
1011
			"	new Top().get().add(\"arg\");\n" + 
1012
			"	^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1013
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
1014
			"----------\n" + 
1015
			"3. WARNING in X.java (at line 6)\n" + 
1016
			"	List raw= new Top().get();\n" + 
1017
			"	^^^^\n" + 
1018
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
1019
			"----------\n" + 
1020
			"4. WARNING in X.java (at line 7)\n" + 
1021
			"	raw.add(\"arg\");\n" + 
1022
			"	^^^^^^^^^^^^^^\n" + 
1023
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
1024
			"----------\n" + 
1025
			"5. WARNING in X.java (at line 8)\n" + 
1026
			"	List<String> unchecked= new Top().get();\n" + 
1027
			"	                        ^^^^^^^^^^^^^^^\n" + 
1028
			"Type safety: The expression of type List needs unchecked conversion to conform to List<String>\n" + 
1029
			"----------\n" + 
1030
			"6. WARNING in X.java (at line 10)\n" + 
1031
			"	List<String> cast= (List<String>) new Top().get();\n" + 
1032
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1033
			"Type safety: Unchecked cast from List to List<String>\n" + 
1034
			"----------\n" + 
1035
			"7. WARNING in X.java (at line 10)\n" + 
1036
			"	List<String> cast= (List<String>) new Top().get();\n" + 
1037
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1038
			"Unnecessary cast from List to List<String>\n" + 
1039
			"----------\n",
1040
			null,
1041
			true,
1042
			customOptions);
1043
}
1044
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 (all in same file)
1045
public void test322817j() {
1046
	Map customOptions = getCompilerOptions();
1047
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
1048
	this.runNegativeTest(
1049
			new String[] {
1050
					"X.java",
1051
					"import java.util.List;\n" +
1052
					"class Top {\n" +
1053
					"    public void set(List arg) { } // OK to warn in 1.5 code\n" +
1054
					"    public List get() { return null; } // OK to warn in 1.5 code\n" +
1055
					"}\n" +
1056
					"class Sub extends Top {\n" +
1057
					"    @Override\n" +
1058
					"    public void set(List arg) { // should not warn (overrides)\n" +
1059
					"        super.set(arg);\n" +
1060
					"        arg.set(0, \"A\"); // should not warn ('arg' is forced raw)\n" +
1061
					"    }\n" +
1062
					"    @Override\n" +
1063
					"    public List get() { // should not warn (overrides)\n" +
1064
					"        return super.get();\n" +
1065
					"    }\n" +
1066
					"}\n" +
1067
					"public class X {\n" +
1068
					"    void run() {\n" +
1069
					"        new Top().get().add(\"arg\");\n" +
1070
					"        List raw= new Top().get(); // OK to warn ('raw' declared here)\n" +
1071
					"        raw.add(\"arg\"); // OK to warn ('raw' declared here)\n" +
1072
					"        List<String> unchecked= new Top().get();\n" +
1073
					"        unchecked.add(\"x\");\n" +
1074
					"        List<String> cast= (List<String>) new Top().get();\n" +
1075
					"        cast.add(\"x\");\n" +
1076
					"    }\n" +
1077
					"}\n"
1078
			},
1079
			"----------\n" + 
1080
			"1. WARNING in X.java (at line 3)\n" + 
1081
			"	public void set(List arg) { } // OK to warn in 1.5 code\n" + 
1082
			"	                ^^^^\n" + 
1083
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
1084
			"----------\n" + 
1085
			"2. WARNING in X.java (at line 4)\n" + 
1086
			"	public List get() { return null; } // OK to warn in 1.5 code\n" + 
1087
			"	       ^^^^\n" + 
1088
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
1089
			"----------\n" + 
1090
			"3. WARNING in X.java (at line 19)\n" + 
1091
			"	new Top().get().add(\"arg\");\n" + 
1092
			"	^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1093
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
1094
			"----------\n" + 
1095
			"4. WARNING in X.java (at line 20)\n" + 
1096
			"	List raw= new Top().get(); // OK to warn (\'raw\' declared here)\n" + 
1097
			"	^^^^\n" + 
1098
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
1099
			"----------\n" + 
1100
			"5. WARNING in X.java (at line 21)\n" + 
1101
			"	raw.add(\"arg\"); // OK to warn (\'raw\' declared here)\n" + 
1102
			"	^^^^^^^^^^^^^^\n" + 
1103
			"Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized\n" + 
1104
			"----------\n" + 
1105
			"6. WARNING in X.java (at line 22)\n" + 
1106
			"	List<String> unchecked= new Top().get();\n" + 
1107
			"	                        ^^^^^^^^^^^^^^^\n" + 
1108
			"Type safety: The expression of type List needs unchecked conversion to conform to List<String>\n" + 
1109
			"----------\n" + 
1110
			"7. WARNING in X.java (at line 24)\n" + 
1111
			"	List<String> cast= (List<String>) new Top().get();\n" + 
1112
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1113
			"Type safety: Unchecked cast from List to List<String>\n" + 
1114
			"----------\n" + 
1115
			"8. WARNING in X.java (at line 24)\n" + 
1116
			"	List<String> cast= (List<String>) new Top().get();\n" + 
1117
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1118
			"Unnecessary cast from List to List<String>\n" + 
1119
			"----------\n",
1120
			null,
1121
			true,
1122
			customOptions);
1123
}
1124
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 (make sure there is no NPE when receiver is null)
1125
public void test322817k() {
1126
	Map customOptions = getCompilerOptions();
1127
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
1128
	this.runNegativeTest(
1129
			new String[] {
1130
					"X.java",
1131
					"import java.util.Arrays;\n" +
1132
					"import java.util.Set;\n" +
1133
					"import java.util.HashSet;\n" +
1134
					"public class X {\n" +
1135
					"    public void foo(String[] elements) {\n" +
1136
					"	     Set set= new HashSet(Arrays.asList(elements));\n" +
1137
					"    }\n" +
1138
					"}\n"
1139
			},
1140
			"----------\n" + 
1141
			"1. WARNING in X.java (at line 6)\n" + 
1142
			"	Set set= new HashSet(Arrays.asList(elements));\n" + 
1143
			"	^^^\n" + 
1144
			"Set is a raw type. References to generic type Set<E> should be parameterized\n" + 
1145
			"----------\n" + 
1146
			"2. WARNING in X.java (at line 6)\n" + 
1147
			"	Set set= new HashSet(Arrays.asList(elements));\n" + 
1148
			"	         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1149
			"Type safety: The constructor HashSet(Collection) belongs to the raw type HashSet. References to generic type HashSet<E> should be parameterized\n" + 
1150
			"----------\n" + 
1151
			"3. WARNING in X.java (at line 6)\n" + 
1152
			"	Set set= new HashSet(Arrays.asList(elements));\n" + 
1153
			"	             ^^^^^^^\n" + 
1154
			"HashSet is a raw type. References to generic type HashSet<E> should be parameterized\n" + 
1155
			"----------\n",
1156
			null,
1157
			true,
1158
			customOptions);
1159
}
539
}
1160
}

Return to bug 322817