### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.356 diff -u -r1.356 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 26 Oct 2010 17:24:15 -0000 1.356 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 10 Dec 2010 07:47:07 -0000 @@ -3530,6 +3530,11 @@ } else if (token.equals("unusedTypeArgs")) { //$NON-NLS-1$ setSeverity(CompilerOptions.OPTION_ReportUnusedTypeArgumentsForMethodInvocation, severity, isEnabling); return; + } else if (token.equals("unavoidableGenericProblems")) { //$NON-NLS-1$ + this.options.put( + CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, + isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); + return; } break; case 'v' : Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.104 diff -u -r1.104 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 22 Oct 2010 22:42:55 -0000 1.104 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 10 Dec 2010 07:47:09 -0000 @@ -343,7 +343,9 @@ if ((invocationStatus & INVOCATION_ARGUMENT_WILDCARD) != 0) { scope.problemReporter().wildcardInvocation((ASTNode)invocationSite, receiverType, method, argumentTypes); } else if (!method.isStatic() && !receiverType.isUnboundWildcard() && method.declaringClass.isRawType() && method.hasSubstitutedParameters()) { - scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method); + if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || !receiver.forcedToBeRaw(scope.referenceContext())) { + scope.problemReporter().unsafeRawInvocation((ASTNode)invocationSite, method); + } } else if (rawOriginalGenericMethod != null || uncheckedBoundCheck || ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 Index: compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java,v retrieving revision 1.136 diff -u -r1.136 CastExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 12 Aug 2010 16:58:28 -0000 1.136 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 10 Dec 2010 07:47:09 -0000 @@ -494,7 +494,9 @@ if (isLegal) { this.expression.computeConversion(scope, castType, expressionType); if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast - scope.problemReporter().unsafeCast(this, scope); + if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || !this.expression.forcedToBeRaw(scope.referenceContext())) { + scope.problemReporter().unsafeCast(this, scope); + } } else { if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){ scope.problemReporter().rawTypeReference(this.type, castType); Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v retrieving revision 1.131 diff -u -r1.131 Expression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 15 Sep 2010 16:10:50 -0000 1.131 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 10 Dec 2010 07:47:09 -0000 @@ -21,6 +21,7 @@ import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.Constant; +import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.Binding; @@ -958,6 +959,30 @@ } return expressionType; } +/** + * Returns true if the receiver is forced to be of raw type either to satisfy the contract imposed + * by a super type or because it *is* raw and the current type has no control over it (i.e the rawness + * originates from some other file. + */ +public boolean forcedToBeRaw(ReferenceContext referenceContext) { + if (this instanceof NameReference) { + final Binding receiverBinding = ((NameReference) this).binding; + if (receiverBinding.isParameter() && (((LocalVariableBinding) receiverBinding).tagBits & TagBits.ForcedToBeRawType) != 0) { + return true; // parameter is forced to be raw since super method uses raw types. + } + } else if (this instanceof MessageSend) { + if (!CharOperation.equals(((MessageSend) this).binding.declaringClass.getFileName(), + referenceContext.compilationResult().getFileName())) { // problem is rooted elsewhere + return true; + } + } else if (this instanceof FieldReference) { + if (!CharOperation.equals(((FieldReference) this).binding.declaringClass.getFileName(), + referenceContext.compilationResult().getFileName())) { // problem is rooted elsewhere + return true; + } + } + return false; +} /** * Returns an object which can be used to identify identical JSR sequence targets Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v retrieving revision 1.235 diff -u -r1.235 CompilerOptions.java --- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 21 Oct 2010 19:59:58 -0000 1.235 +++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 10 Dec 2010 07:47:09 -0000 @@ -87,6 +87,7 @@ public static final String OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"; //$NON-NLS-1$ public static final String OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable"; //$NON-NLS-1$ public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$ + public static final String OPTION_ReportUnavoidableGenericTypeProblems = "org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems"; //$NON-NLS-1$ public static final String OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$ public static final String OPTION_ReportRawTypeReference = "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; //$NON-NLS-1$ public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$ @@ -357,6 +358,8 @@ public boolean ignoreMethodBodies; /** Raise null related warnings for variables tainted inside an assert statement (java 1.4 and above)*/ public boolean includeNullInfoFromAsserts; + /** Controls whether forced generic type problems get reported */ + public boolean reportUnavoidableGenericTypeProblems; // keep in sync with warningTokenToIrritant and warningTokenFromIrritant public final static String[] warningTokens = { @@ -871,6 +874,7 @@ optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference, this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable, this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess)); + optionsMap.put(OPTION_ReportUnavoidableGenericTypeProblems, this.reportUnavoidableGenericTypeProblems ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportUncheckedTypeOperation, getSeverityString(UncheckedTypeOperation)); optionsMap.put(OPTION_ReportRawTypeReference, getSeverityString(RawTypeReference)); optionsMap.put(OPTION_ReportFinalParameterBound, getSeverityString(FinalParameterBound)); @@ -1012,6 +1016,8 @@ // constructor/setter parameter hiding this.reportSpecialParameterHidingField = false; + this.reportUnavoidableGenericTypeProblems = true; + // check javadoc comments tags this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; this.reportInvalidJavadocTags = false; @@ -1193,6 +1199,13 @@ this.reportSpecialParameterHidingField = false; } } + if ((optionValue = optionsMap.get(OPTION_ReportUnavoidableGenericTypeProblems)) != null) { + if (ENABLED.equals(optionValue)) { + this.reportUnavoidableGenericTypeProblems = true; + } else if (DISABLED.equals(optionValue)) { + this.reportUnavoidableGenericTypeProblems = false; + } + } if ((optionValue = optionsMap.get(OPTION_ReportDeadCodeInTrivialIfStatement )) != null) { if (ENABLED.equals(optionValue)) { this.reportDeadCodeInTrivialIfStatement = true; @@ -1516,6 +1529,7 @@ buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- report unavoidable generic type problems : ").append(this.reportUnavoidableGenericTypeProblems ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$ buf.append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); //$NON-NLS-1$ buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$ Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java,v retrieving revision 1.36 diff -u -r1.36 Binding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java 14 Jul 2010 10:37:16 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java 10 Dec 2010 07:47:10 -0000 @@ -94,6 +94,9 @@ public boolean isVolatile() { return false; } + public boolean isParameter() { + return false; + } /* API * Answer the problem id associated with the receiver. * NoError if the receiver is a valid binding. Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java,v retrieving revision 1.48 diff -u -r1.48 LocalVariableBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 22 Oct 2010 22:42:56 -0000 1.48 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 10 Dec 2010 07:47:10 -0000 @@ -41,6 +41,7 @@ public LocalVariableBinding(char[] name, TypeBinding type, int modifiers, boolean isArgument) { super(name, type, modifiers, isArgument ? Constant.NotAConstant : null); if (isArgument) this.tagBits |= TagBits.IsArgument; + this.tagBits &= ~TagBits.ForcedToBeRawType; } // regular local variable or argument @@ -244,4 +245,8 @@ } return s; } + + public boolean isParameter() { + return ((this.tagBits & TagBits.IsArgument) != 0); + } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java,v retrieving revision 1.113 diff -u -r1.113 MethodVerifier.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 17 Aug 2010 14:50:42 -0000 1.113 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 10 Dec 2010 07:47:10 -0000 @@ -158,7 +158,7 @@ if (reportIncompatibleReturnTypeError(currentMethod, inheritedMethod)) continue nextMethod; } - + reportRawReferences(currentMethod, inheritedMethod); // if they were deferred, emit them now. if (currentMethod.thrownExceptions != Binding.NO_EXCEPTIONS) checkExceptions(currentMethod, inheritedMethod); if (inheritedMethod.isFinal()) @@ -185,6 +185,9 @@ } } +public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) { + // nothing to do here. Real action happens at 1.5+ +} void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) { // Remember that interfaces can only define public instance methods if (concreteMethod.isStatic()) Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.120 diff -u -r1.120 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 6 Nov 2010 12:24:51 -0000 1.120 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 10 Dec 2010 07:47:10 -0000 @@ -10,8 +10,16 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; + +import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.Argument; +import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeParameter; +import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; import org.eclipse.jdt.internal.compiler.util.SimpleSet; @@ -398,6 +406,94 @@ return false; } + +void reportRawReferences() { + CompilerOptions compilerOptions = this.type.scope.compilerOptions(); + if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all + || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined + return; + } + /* Code below is only for a method that does not override/implement a super type method. If it were to, + it would have been handled in checkAgainstInheritedMethods. + */ + Object [] methodArray = this.currentMethods.valueTable; + for (int s = methodArray.length; --s >= 0;) { + if (methodArray[s] == null) continue; + MethodBinding[] current = (MethodBinding[]) methodArray[s]; + for (int i = 0, length = current.length; i < length; i++) { + MethodBinding currentMethod = current[i]; + if ((currentMethod.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) { + AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod(); + if (methodDecl == null) return; + TypeBinding [] parameterTypes = currentMethod.parameters; + Argument[] arguments = methodDecl.arguments; + for (int j = 0, size = currentMethod.parameters.length; j < size; j++) { + TypeBinding parameterType = parameterTypes[j]; + Argument arg = arguments[j]; + if (parameterType.leafComponentType().isRawType() + && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore + && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) { + methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType); + } + } + if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration) { + TypeReference returnType = ((MethodDeclaration) methodDecl).returnType; + TypeBinding methodType = currentMethod.returnType; + if (returnType != null) { + if (methodType.leafComponentType().isRawType() + && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore + && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0) { + methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType); + } + } + } + } + } + } +} +public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) { + CompilerOptions compilerOptions = this.type.scope.compilerOptions(); + if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all + || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined + return; + } + AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod(); + if (methodDecl == null) return; + TypeBinding [] parameterTypes = currentMethod.parameters; + TypeBinding [] inheritedParameterTypes = inheritedMethod.parameters; + Argument[] arguments = methodDecl.arguments; + for (int j = 0, size = currentMethod.parameters.length; j < size; j++) { + TypeBinding parameterType = parameterTypes[j]; + TypeBinding inheritedParameterType = inheritedParameterTypes[j]; + Argument arg = arguments[j]; + if (parameterType.leafComponentType().isRawType()) { + if (inheritedParameterType.leafComponentType().isRawType()) { + arg.binding.tagBits |= TagBits.ForcedToBeRawType; + } else { + if (compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore + && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) { + methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType); + } + } + } + } + TypeReference returnType = null; + if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration && (returnType = ((MethodDeclaration) methodDecl).returnType) != null) { + final TypeBinding inheritedMethodType = inheritedMethod.returnType; + final TypeBinding methodType = currentMethod.returnType; + if (methodType.leafComponentType().isRawType()) { + if (inheritedMethodType.leafComponentType().isRawType()) { + // + } else { + if ((returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0 + && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { + methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType); + } + } + } + } + } + void checkMethods() { boolean mustImplementAbstractMethods = mustImplementAbstractMethods(); boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods @@ -903,6 +999,8 @@ this.type.detectAnnotationCycle(); super.verify(); + + reportRawReferences(); for (int i = this.type.typeVariables.length; --i >= 0;) { TypeVariableBinding var = this.type.typeVariables[i]; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v retrieving revision 1.182 diff -u -r1.182 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 27 Oct 2010 02:55:30 -0000 1.182 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 10 Dec 2010 07:47:11 -0000 @@ -1365,7 +1365,7 @@ if (count < size) System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count], 0, count); } - + final boolean reportUnavoidableGenericTypeProblems = this.scope.compilerOptions().reportUnavoidableGenericTypeProblems; boolean foundArgProblem = false; Argument[] arguments = methodDecl.arguments; if (arguments != null) { @@ -1377,7 +1377,20 @@ if (arg.annotations != null) { method.tagBits |= TagBits.HasParameterAnnotations; } - TypeBinding parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 + boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; + TypeBinding parameterType; + if (deferRawTypeCheck) { + arg.type.bits |= ASTNode.IgnoreRawTypeCheck; + } + try { + parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/); + } finally { + if (deferRawTypeCheck) { + arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck; + } + } + if (parameterType == null) { foundArgProblem = true; } else if (parameterType == TypeBinding.VOID) { @@ -1410,7 +1423,19 @@ method.returnType = null; foundReturnTypeProblem = true; } else { - TypeBinding methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 + boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0; + TypeBinding methodType; + if (deferRawTypeCheck) { + returnType.bits |= ASTNode.IgnoreRawTypeCheck; + } + try { + methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/); + } finally { + if (deferRawTypeCheck) { + returnType.bits &= ~ASTNode.IgnoreRawTypeCheck; + } + } if (methodType == null) { foundReturnTypeProblem = true; } else if (methodType.isArrayType() && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java,v retrieving revision 1.44 diff -u -r1.44 TagBits.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 21 Sep 2010 14:02:58 -0000 1.44 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 10 Dec 2010 07:47:11 -0000 @@ -35,6 +35,9 @@ // local variable long NotInitialized = ASTNode.Bit9; + + // local variable + long ForcedToBeRawType = ASTNode.Bit10; // set when method has argument(s) that couldn't be resolved long HasUnresolvedArguments = ASTNode.Bit10; Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.426 diff -u -r1.426 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 19 Nov 2010 14:22:00 -0000 1.426 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 10 Dec 2010 07:47:12 -0000 @@ -7130,6 +7130,9 @@ if (this.options.sourceLevel < ClassFileConstants.JDK1_5) return; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305259 int severity = computeSeverity(IProblem.UnsafeTypeConversion); if (severity == ProblemSeverities.Ignore) return; + if (!this.options.reportUnavoidableGenericTypeProblems && expression.forcedToBeRaw(this.referenceContext)) { + return; + } this.handle( IProblem.UnsafeTypeConversion, new String[] { new String(expressionType.readableName()), new String(expectedType.readableName()), new String(expectedType.erasure().readableName()) }, Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java,v retrieving revision 1.80 diff -u -r1.80 DefaultCodeFormatter.java --- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 22 Feb 2010 11:01:46 -0000 1.80 +++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java 10 Dec 2010 07:47:12 -0000 @@ -336,6 +336,7 @@ optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED); optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED); optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, CompilerOptions.DISABLED); + optionsMap.put(CompilerOptions.OPTION_ReportUnavoidableGenericTypeProblems, CompilerOptions.ENABLED); optionsMap.put(CompilerOptions.OPTION_MaxProblemPerUnit, String.valueOf(100)); optionsMap.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.DISABLED); this.defaultCompilerOptions = optionsMap; Index: model/org/eclipse/jdt/core/JavaCore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v retrieving revision 1.655 diff -u -r1.655 JavaCore.java --- model/org/eclipse/jdt/core/JavaCore.java 6 Oct 2010 13:57:36 -0000 1.655 +++ model/org/eclipse/jdt/core/JavaCore.java 10 Dec 2010 07:47:13 -0000 @@ -900,6 +900,22 @@ */ public static final String COMPILER_PB_RAW_TYPE_REFERENCE = PLUGIN_ID + ".compiler.problem.rawTypeReference"; //$NON-NLS-1$ /** + * Compiler option ID: Reporting of Unavoidable Generic Type Problems. + *

When enabled, the compiler will issue an error or warning even when it detects a generic type problem + * that could not have been avoided by the programmer. As an example, a type may be forced to use raw types + * in its method signatures and return types because the methods it overrides from a super type are declared to + * use raw types in the first place. + *

+ *
Option id:
"org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems"
+ *
Possible values:
{ "enabled", "disabled" }
+ *
Default:
"enabled"
+ *
+ * @since 3.7 + * @category CompilerOptionID + */ + public static final String COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS = PLUGIN_ID + ".compiler.problem.unavoidableGenericTypeProblems"; //$NON-NLS-1$ + + /** * Compiler option ID: Reporting final Bound for Type Parameter. *

When enabled, the compiler will issue an error or a warning whenever a generic type parameter is associated with a * bound corresponding to a final type; since final types cannot be further extended, the parameter is pretty useless. #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.220 diff -u -r1.220 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 19 Nov 2010 14:21:58 -0000 1.220 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Dec 2010 07:47:19 -0000 @@ -1800,7 +1800,7 @@ "