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 / +6 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 
347
					|| !(receiver instanceof NameReference)
348
					|| !(((NameReference) receiver).binding.isParameter())
349
					|| (((LocalVariableBinding) (((NameReference) receiver).binding)).tagBits & TagBits.ForcedToBeRawType) == 0) {
350
				scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method);
351
			}
347
		} else if (rawOriginalGenericMethod != null 
352
		} else if (rawOriginalGenericMethod != null 
348
				|| uncheckedBoundCheck
353
				|| uncheckedBoundCheck
349
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
354
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
(-)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/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 (+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 (+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;
(-)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.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 (+254 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
739
public void test322817g() {
740
	Map customOptions = getCompilerOptions();
741
	customOptions.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.DISABLED);
742
	this.runNegativeTest(
743
			new String[] {
744
					"X.java",
745
					"import java.util.List;\n" +
746
					"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
					"}\n" +
750
					"class Sub extends Top {\n" +
751
					"    @Override\n" +
752
					"    public void set(List arg) { // should not warn (overrides)\n" +
753
					"        super.set(arg);\n" +
754
					"        arg.set(0, \"A\"); // should not warn ('arg' is forced raw)\n" +
755
					"    }\n" +
756
					"    @Override\n" +
757
					"    public List get() { // should not warn (overrides)\n" +
758
					"        return super.get();\n" +
759
					"    }\n" +
760
					"}\n" +
761
					"public class X {\n" +
762
//					"    void run() {\n" +
763
//					"        new Top().get().add(\"arg\"); // should not warn (uses raw API)\n" +
764
//					"        List raw= new Top().get(); // OK to warn ('raw' declared here)\n" +
765
//					"        raw.add(\"arg\"); // OK to warn ('raw' declared here)\n" +
766
//					"        // When Top#get() is generified, both of the following will fail\n" +
767
//					"        // with a compile error if type arguments don't match:\n" +
768
//					"        List<String> unchecked= new Top().get(); // should not warn (forced)\n" +
769
//					"        unchecked.add(\"x\");\n" +
770
//					"        // Should not warn about unchecked cast, but should warn about\n" +
771
//					"        // unnecessary cast:\n" +
772
//					"        List<String> cast= (List<String>) new Top().get();\n" +
773
//					"        cast.add(\"x\");\n" +
774
//					"    }\n" +
775
					"}\n"
776
			},
777
			"----------\n" + 
778
			"1. WARNING in X.java (at line 3)\n" + 
779
			"	public void set(List arg) { } // OK to warn in 1.5 code\n" + 
780
			"	                ^^^^\n" + 
781
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
782
			"----------\n" + 
783
			"2. WARNING in X.java (at line 4)\n" + 
784
			"	public List get() { return null; } // OK to warn in 1.5 code\n" + 
785
			"	       ^^^^\n" + 
786
			"List is a raw type. References to generic type List<E> should be parameterized\n" + 
787
			"----------\n",
788
			null,
789
			true,
790
			customOptions);
791
}
792
539
}
793
}

Return to bug 322817