### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java,v retrieving revision 1.37 diff -u -r1.37 QualifiedThisReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java 13 Oct 2006 19:20:46 -0000 1.37 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java 28 Nov 2007 18:11:36 -0000 @@ -76,7 +76,7 @@ constant = Constant.NotAConstant; // X.this is not a param/raw type as denoting enclosing instance TypeBinding type = this.qualification.resolveType(scope, true /* check bounds*/); - if (type == null) return null; + if (type == null || !type.isValidBinding()) return null; // X.this is not a param/raw type as denoting enclosing instance type = type.erasure(); @@ -109,7 +109,7 @@ checkAccess(scope.methodScope()); } // if depth>0, path emulation will diagnose bad scenarii - return this.resolvedType; + return this.resolvedType; } public StringBuffer printExpression(int indent, StringBuffer output) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java,v retrieving revision 1.37 diff -u -r1.37 TypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java 6 Mar 2007 02:38:48 -0000 1.37 +++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java 28 Nov 2007 18:11:37 -0000 @@ -28,14 +28,6 @@ public abstract class TypeReference extends Expression { -public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { - return flowInfo; -} - -// allows us to trap completion & selection nodes -public void aboutToResolve(Scope scope) { - // default implementation: do nothing -} /* * Answer a base type reference (can be an array of base type). */ @@ -84,6 +76,14 @@ return new ArrayTypeReference(TypeBinding.LONG.simpleName, dim, 0); } } + +// allows us to trap completion & selection nodes +public void aboutToResolve(Scope scope) { + // default implementation: do nothing +} +public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { + return flowInfo; +} public void checkBounds(Scope scope) { // only parameterized type references have bounds } @@ -106,96 +106,89 @@ * @return char[][] */ public abstract char [][] getTypeName() ; -public boolean isTypeReference() { - return true; -} -public TypeBinding resolveSuperType(ClassScope scope) { - // assumes the implementation of resolveType(ClassScope) will call back to detect cycles - if (resolveType(scope) == null) return null; - - if (this.resolvedType.isTypeVariable()) { - this.resolvedType = new ProblemReferenceBinding(getTypeName(), (ReferenceBinding) this.resolvedType, ProblemReasons.IllegalSuperTypeVariable); - reportInvalidType(scope); - return null; - } - return this.resolvedType; -} - -public final TypeBinding resolveType(BlockScope blockScope) { - return resolveType(blockScope, true /* checkbounds if any */); -} - -public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { +private TypeBinding internalResolveType(Scope scope) { // handle the error here this.constant = Constant.NotAConstant; - if (this.resolvedType != null) // is a shared type reference which was already resolved - return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error - + if (this.resolvedType != null) {// is a shared type reference which was already resolved + return this.resolvedType.isValidBinding() + ? this.resolvedType + : this.resolvedType.closestMatch(); // already reported error + } + TypeBinding type = this.resolvedType = getTypeBinding(scope); - if (type == null) + if (type == null) { return null; // detected cycle while resolving hierarchy + } + boolean hasError = false; if (!type.isValidBinding()) { + hasError = true; reportInvalidType(scope); - return null; + type = type.closestMatch(); + if (type == null) { + return null; + } } if (type.isArrayType() && ((ArrayBinding) type).leafComponentType == TypeBinding.VOID) { scope.problemReporter().cannotAllocateVoidArray(this); return null; } - if (isTypeUseDeprecated(type, scope)) reportDeprecatedType(type, scope); type = scope.environment().convertToRawType(type); if (type.leafComponentType().isRawType() && (this.bits & ASTNode.IgnoreRawTypeCheck) == 0 - && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { + && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { scope.problemReporter().rawTypeReference(this, type); - } + } + if (hasError) { + // do not store the computed type, keep the problem type instead + return type; + } return this.resolvedType = type; } -public TypeBinding resolveType(ClassScope scope) { - // handle the error here - this.constant = Constant.NotAConstant; - if (this.resolvedType != null) // is a shared type reference which was already resolved - return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error +public boolean isTypeReference() { + return true; +} - TypeBinding type = this.resolvedType = getTypeBinding(scope); - if (type == null) - return null; // detected cycle while resolving hierarchy - if (!type.isValidBinding()) { +protected void reportDeprecatedType(TypeBinding type, Scope scope) { + scope.problemReporter().deprecatedType(type, this); +} + +protected void reportInvalidType(Scope scope) { + scope.problemReporter().invalidType(this, this.resolvedType); +} + +public TypeBinding resolveSuperType(ClassScope scope) { + // assumes the implementation of resolveType(ClassScope) will call back to detect cycles + TypeBinding superType = resolveType(scope); + if (superType == null) return null; + + if (superType.isTypeVariable()) { + this.resolvedType = new ProblemReferenceBinding(getTypeName(), (ReferenceBinding)this.resolvedType, ProblemReasons.IllegalSuperTypeVariable); reportInvalidType(scope); return null; } - if (type.isArrayType() && ((ArrayBinding) type).leafComponentType == TypeBinding.VOID) { - scope.problemReporter().cannotAllocateVoidArray(this); - return null; - } - if (isTypeUseDeprecated(type, scope)) - reportDeprecatedType(type, scope); - - type = scope.environment().convertToRawType(type); - if (type.leafComponentType().isRawType() - && (this.bits & ASTNode.IgnoreRawTypeCheck) == 0 - && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) { - scope.problemReporter().rawTypeReference(this, type); - } - return this.resolvedType = type; + return superType; } -public TypeBinding resolveTypeArgument(BlockScope blockScope, ReferenceBinding genericType, int rank) { - return resolveType(blockScope, true /* check bounds*/); +public final TypeBinding resolveType(BlockScope blockScope) { + return resolveType(blockScope, true /* checkbounds if any */); } -public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) { - return resolveType(classScope); +public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { + return internalResolveType(scope); +} + +public TypeBinding resolveType(ClassScope scope) { + return internalResolveType(scope); } -protected void reportInvalidType(Scope scope) { - scope.problemReporter().invalidType(this, this.resolvedType); +public TypeBinding resolveTypeArgument(BlockScope blockScope, ReferenceBinding genericType, int rank) { + return resolveType(blockScope, true /* check bounds*/); } -protected void reportDeprecatedType(TypeBinding type, Scope scope) { - scope.problemReporter().deprecatedType(type, this); +public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) { + return resolveType(classScope); } public abstract void traverse(ASTVisitor visitor, BlockScope scope); public abstract void traverse(ASTVisitor visitor, ClassScope scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v retrieving revision 1.99 diff -u -r1.99 SingleNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 9 Nov 2007 08:42:33 -0000 1.99 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 28 Nov 2007 18:11:37 -0000 @@ -806,7 +806,7 @@ constant = Constant.NotAConstant; if (binding instanceof ProblemFieldBinding) { scope.problemReporter().invalidField(this, (FieldBinding) binding); - } else if (binding instanceof ProblemReferenceBinding) { + } else if (this.binding instanceof ProblemReferenceBinding || this.binding instanceof MissingTypeBinding) { scope.problemReporter().invalidType(this, (TypeBinding) binding); } else { scope.problemReporter().unresolvableReference(this, binding); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java,v retrieving revision 1.29 diff -u -r1.29 ArrayTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java 10 May 2006 18:03:43 -0000 1.29 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java 28 Nov 2007 18:11:34 -0000 @@ -53,7 +53,9 @@ } protected TypeBinding getTypeBinding(Scope scope) { - if (this.resolvedType != null) return this.resolvedType; + if (this.resolvedType != null) { + return this.resolvedType; + } if (dimensions > 255) { scope.problemReporter().tooManyDimensions(this); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java,v retrieving revision 1.11 diff -u -r1.11 JavadocImplicitTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java 6 Mar 2007 02:38:48 -0000 1.11 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java 28 Nov 2007 18:11:34 -0000 @@ -67,16 +67,26 @@ if (this.resolvedType != null) // is a shared type reference which was already resolved return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error - this.resolvedType = scope.enclosingSourceType(); - if (this.resolvedType == null) + TypeBinding type = this.resolvedType = scope.enclosingSourceType(); + if (type == null) { return null; // detected cycle while resolving hierarchy - if (!this.resolvedType.isValidBinding()) { + } + boolean hasError = false; + if (!type.isValidBinding()) { + hasError = true; reportInvalidType(scope); - return null; + type = type.closestMatch(); + if (type == null) { + return null; + } + } + if (isTypeUseDeprecated(type, scope)) + reportDeprecatedType(type, scope); + if (hasError) { + // do not store the computed type, keep the problem type instead + return type; } - if (isTypeUseDeprecated(this.resolvedType, scope)) - reportDeprecatedType(this.resolvedType, scope); - return this.resolvedType; + return this.resolvedType = type; } protected void reportInvalidType(Scope scope) { 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.89 diff -u -r1.89 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 14 Nov 2007 12:06:31 -0000 1.89 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 28 Nov 2007 18:11:34 -0000 @@ -428,14 +428,15 @@ */ public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) { - if (type.isArrayType()) + if (type.isArrayType()) { type = ((ArrayBinding) type).leafComponentType; + } if (type.isBaseType()) return false; ReferenceBinding refType = (ReferenceBinding) type; // ignore references insing Javadoc comments - if ((this.bits & ASTNode.InsideJavadoc) ==0 && + if ((this.bits & ASTNode.InsideJavadoc) == 0 && (refType.isPrivate() || refType.isLocalType()) && !scope.isDefinedInType(refType)) { // ignore cases where type is used from within inside itself ((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed; Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v retrieving revision 1.71 diff -u -r1.71 AllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 21 Nov 2007 14:15:24 -0000 1.71 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 28 Nov 2007 18:11:34 -0000 @@ -241,7 +241,7 @@ checkParameterizedAllocation: { if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X.Y() ReferenceBinding currentType = (ReferenceBinding)this.resolvedType; - if (currentType == null) return null; + if (currentType == null) return currentType; do { // isStatic() is answering true for toplevel types if ((currentType.modifiers & ClassFileConstants.AccStatic) != 0) break checkParameterizedAllocation; @@ -262,7 +262,7 @@ // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = false; // typeChecks all arguments + boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; @@ -274,6 +274,11 @@ } } if (argHasError) { + if (this.arguments != null) { // still attempt to resolve arguments + for (int i = 0, max = this.arguments.length; i < max; i++) { + this.arguments[i].resolveType(scope); + } + } return null; } } @@ -323,8 +328,9 @@ return this.resolvedType; } } - if (this.resolvedType == null) + if (this.resolvedType == null || !this.resolvedType.isValidBinding()) { return null; + } // null type denotes fake allocation for enum constant inits if (this.type != null && !this.resolvedType.canBeInstantiated()) { @@ -333,8 +339,13 @@ } ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType; if (!(binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { - if (binding.declaringClass == null) + if (binding.declaringClass == null) { binding.declaringClass = allocationType; + } + if (this.type != null && !this.type.resolvedType.isValidBinding()) { + // problem already got signaled on type reference, do not report secondary problem + return null; + } scope.problemReporter().invalidConstructor(this, binding); return this.resolvedType; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java,v retrieving revision 1.21 diff -u -r1.21 JavadocSingleTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java 10 Apr 2007 19:03:10 -0000 1.21 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java 28 Nov 2007 18:11:35 -0000 @@ -15,16 +15,17 @@ import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; +import org.eclipse.jdt.internal.compiler.lookup.InvocationSite; import org.eclipse.jdt.internal.compiler.lookup.PackageBinding; import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.ProblemBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; -import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.eclipse.jdt.internal.compiler.lookup.Scope; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; -public class JavadocSingleTypeReference extends SingleTypeReference { +public class JavadocSingleTypeReference extends SingleTypeReference implements InvocationSite { public int tagSourceStart, tagSourceEnd; public PackageBinding packageBinding; @@ -64,24 +65,30 @@ // handle the error here this.constant = Constant.NotAConstant; if (this.resolvedType != null)// is a shared type reference which was already resolved - return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error - - this.resolvedType = getTypeBinding(scope); - if (!this.resolvedType.isValidBinding()) { - char[][] tokens = { this.token }; - Binding binding = scope.getTypeOrPackage(tokens); - if (binding instanceof PackageBinding) { - this.packageBinding = (PackageBinding) binding; - } else { - if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) { - ReferenceBinding closestMatch = ((ProblemReferenceBinding)this.resolvedType).closestMatch(); - if (closestMatch != null && closestMatch.isTypeVariable()) { - this.resolvedType = closestMatch; // ignore problem as we want report specific javadoc one instead - return this.resolvedType; - } + return this.resolvedType.isValidBinding() + ? this.resolvedType + : this.resolvedType.closestMatch(); // already reported error + + Binding binding = scope.getBinding(this.token, Binding.TYPE|Binding.PACKAGE, this, true /*resolve*/); + if (binding instanceof PackageBinding) { + this.packageBinding = (PackageBinding) binding; + return null; + } else if (binding.isValidBinding()) { + this.resolvedType = (TypeBinding) binding; + } else { + if (binding instanceof ProblemBinding) { + binding = scope.getType(this.token); // expect to find a problem reference binding back + if (!(binding instanceof ReferenceBinding)) return null; // cannot report issue + } + this.resolvedType = (TypeBinding) binding; + if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) { + TypeBinding closestMatch = this.resolvedType.closestMatch(); + if (closestMatch != null && closestMatch.isTypeVariable()) { + this.resolvedType = closestMatch; // ignore problem as we want report specific javadoc one instead + return this.resolvedType; } - reportInvalidType(scope); } + reportInvalidType(scope); return null; } if (isTypeUseDeprecated(this.resolvedType, scope)) @@ -103,4 +110,28 @@ public TypeBinding resolveType(ClassScope classScope) { return internalResolveType(classScope); } + + public TypeBinding[] genericTypeArguments() { + return null; + } + + public boolean isSuperAccess() { + return false; + } + + public boolean isTypeAccess() { + return false; + } + + public void setActualReceiverType(ReferenceBinding receiverType) { + // do nothing + } + + public void setDepth(int depth) { + // do nothing + } + + public void setFieldIndex(int depth) { + // do nothing + } } Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java,v retrieving revision 1.33 diff -u -r1.33 JavadocMessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 27 Apr 2007 15:51:38 -0000 1.33 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 28 Nov 2007 18:11:35 -0000 @@ -129,6 +129,10 @@ } } if (!this.binding.isValidBinding()) { + if (!this.receiver.resolvedType.isValidBinding()) { + // problem already got signaled on receiver, do not report secondary problem + return null; + } if (this.binding.declaringClass == null) { if (this.actualReceiverType instanceof ReferenceBinding) { this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType; Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java,v retrieving revision 1.25 diff -u -r1.25 JavadocFieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 16 Nov 2007 13:53:36 -0000 1.25 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java 28 Nov 2007 18:11:34 -0000 @@ -68,6 +68,10 @@ } // When there's no valid field binding, try to resolve possible method reference without parenthesis if (!fieldBinding.isValidBinding() || !(fieldBinding instanceof FieldBinding)) { + if (!this.receiver.resolvedType.isValidBinding()) { + // problem already got signaled on receiver, do not report secondary problem + return null; + } if (this.receiverType instanceof ReferenceBinding) { ReferenceBinding refBinding = (ReferenceBinding) this.receiverType; MethodBinding[] methodBindings = refBinding.getMethods(this.token); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java,v retrieving revision 1.45 diff -u -r1.45 ParameterizedQualifiedTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 9 May 2007 17:18:18 -0000 1.45 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 28 Nov 2007 18:11:35 -0000 @@ -12,6 +12,7 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ASTVisitor; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.Constant; import org.eclipse.jdt.internal.compiler.lookup.*; @@ -210,8 +211,21 @@ TypeVariableBinding[] typeVariables = currentType.typeVariables(); if (typeVariables == Binding.NO_TYPE_VARIABLES) { // check generic - scope.problemReporter().nonGenericTypeCannotBeParameterized(i, this, currentType, argTypes); - return null; + if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // below 1.5, already reported as syntax error + scope.problemReporter().nonGenericTypeCannotBeParameterized(i, this, currentType, argTypes); + } + if (i < max-1) { // intermediate token + return null; + } + this.resolvedType = (qualifiedType != null && qualifiedType.isParameterizedType()) + ? scope.environment().createParameterizedType(currentType, null, qualifiedType) + : currentType; + if (this.dimensions > 0) { + if (dimensions > 255) + scope.problemReporter().tooManyDimensions(this); + this.resolvedType = scope.createArrayType(this.resolvedType, dimensions); + } + return this.resolvedType; } else if (argLength != typeVariables.length) { // check arity scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); return null; @@ -251,7 +265,6 @@ reportDeprecatedType(qualifiedType, scope); this.resolvedType = qualifiedType; } -// this.resolvedType = qualifiedType; // array type ? if (this.dimensions > 0) { if (dimensions > 255) Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java,v retrieving revision 1.42 diff -u -r1.42 QualifiedTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 9 May 2007 17:18:18 -0000 1.42 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 28 Nov 2007 18:11:36 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.lookup.*; import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; @@ -41,11 +42,11 @@ this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding); } else { this.resolvedType = scope.getMemberType(this.tokens[tokenIndex], (ReferenceBinding) this.resolvedType); - if (this.resolvedType instanceof ProblemReferenceBinding) { + if (!this.resolvedType.isValidBinding()) { ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) this.resolvedType; this.resolvedType = new ProblemReferenceBinding( - org.eclipse.jdt.core.compiler.CharOperation.subarray(this.tokens, 0, tokenIndex + 1), - problemBinding.closestMatch(), + CharOperation.subarray(this.tokens, 0, tokenIndex + 1), + problemBinding.closestReferenceMatch(), this.resolvedType.problemId()); } } Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v retrieving revision 1.113 diff -u -r1.113 FieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 9 Nov 2007 08:42:33 -0000 1.113 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 28 Nov 2007 18:11:34 -0000 @@ -528,7 +528,7 @@ this.receiver.bits |= DisableUnnecessaryCastCheck; // will check later on receiverCast = true; } - this.receiverType = receiver.resolveType(scope); + this.receiverType = this.receiver.resolveType(scope); if (this.receiverType == null) { constant = Constant.NotAConstant; return null; @@ -543,6 +543,10 @@ FieldBinding fieldBinding = this.codegenBinding = this.binding = scope.getField(this.receiverType, token, this); if (!fieldBinding.isValidBinding()) { constant = Constant.NotAConstant; + if (!this.receiver.resolvedType.isValidBinding()) { + // problem already got signaled on receiver, do not report secondary problem + return null; + } scope.problemReporter().invalidField(this, this.receiverType); return null; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java,v retrieving revision 1.28 diff -u -r1.28 SingleTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java 10 May 2007 16:05:23 -0000 1.28 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java 28 Nov 2007 18:11:37 -0000 @@ -59,12 +59,15 @@ } public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) { - - TypeBinding memberType = scope.getMemberType(token, enclosingType); + TypeBinding memberType = this.resolvedType = scope.getMemberType(token, enclosingType); + boolean hasError = false; if (!memberType.isValidBinding()) { - this.resolvedType = memberType; + hasError = true; scope.problemReporter().invalidEnclosingType(this, memberType, enclosingType); - return null; + memberType = ((ReferenceBinding)memberType).closestMatch(); + if (memberType == null) { + return null; + } } if (isTypeUseDeprecated(memberType, scope)) scope.problemReporter().deprecatedType(memberType, this); @@ -74,6 +77,10 @@ && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){ scope.problemReporter().rawTypeReference(this, memberType); } + if (hasError) { + // do not store the computed type, keep the problem type instead + return memberType; + } return this.resolvedType = memberType; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java,v retrieving revision 1.40 diff -u -r1.40 ParameterizedSingleTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 9 May 2007 17:18:18 -0000 1.40 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 28 Nov 2007 18:11:35 -0000 @@ -12,6 +12,7 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ASTVisitor; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.Constant; import org.eclipse.jdt.internal.compiler.lookup.*; @@ -159,8 +160,17 @@ TypeVariableBinding[] typeVariables = currentType.typeVariables(); if (typeVariables == Binding.NO_TYPE_VARIABLES) { // check generic - scope.problemReporter().nonGenericTypeCannotBeParameterized(this, currentType, argTypes); - return null; + if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // below 1.5, already reported as syntax error + scope.problemReporter().nonGenericTypeCannotBeParameterized(0, this, currentType, argTypes); + } + this.resolvedType = currentType; + // array type ? + if (this.dimensions > 0) { + if (dimensions > 255) + scope.problemReporter().tooManyDimensions(this); + this.resolvedType = scope.createArrayType(this.resolvedType, dimensions); + } + return this.resolvedType; } else if (argLength != typeVariables.length) { // check arity scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); return null; Index: compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java,v retrieving revision 1.60 diff -u -r1.60 Argument.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 24 Sep 2007 22:49:54 -0000 1.60 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 28 Nov 2007 18:11:34 -0000 @@ -125,7 +125,7 @@ } break; } - if (exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) { + if (exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null && exceptionType.isValidBinding()) { scope.problemReporter().cannotThrowType(this.type, exceptionType); hasError = true; // fall thru to create the variable - avoids additional errors because the variable is missing Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.86 diff -u -r1.86 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 21 Nov 2007 14:15:24 -0000 1.86 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 28 Nov 2007 18:11:35 -0000 @@ -256,7 +256,7 @@ } else { receiverType = this.type.resolveType(scope, true /* check bounds*/); checkParameterizedAllocation: { - if (receiverType == null) break checkParameterizedAllocation; + if (receiverType == null || !receiverType.isValidBinding()) break checkParameterizedAllocation; if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X.Y() ReferenceBinding currentType = (ReferenceBinding)receiverType; do { @@ -275,23 +275,31 @@ } } } - if (receiverType == null) { + if (receiverType == null || !receiverType.isValidBinding()) { hasError = true; } + // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; + boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { - TypeReference typeReference = this.typeArguments[i]; - TypeBinding argType = typeReference.resolveType(scope, true /* check bounds*/); - if (argType == null) { - if (typeReference instanceof Wildcard) { - scope.problemReporter().illegalUsageOfWildcard(typeReference); - } - return null; // error already reported + TypeReference typeReference = this.typeArguments[i]; + if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) { + argHasError = true; + } + if (argHasError && typeReference instanceof Wildcard) { + scope.problemReporter().illegalUsageOfWildcard(typeReference); } - this.genericTypeArguments[i] = argType; + } + if (argHasError) { + if (this.arguments != null) { // still attempt to resolve arguments + for (int i = 0, max = this.arguments.length; i < max; i++) { + this.arguments[i].resolveType(scope); + } + } + return null; } } @@ -311,32 +319,37 @@ } } } + // limit of fault-tolerance if (hasError) { if (receiverType instanceof ReferenceBinding) { ReferenceBinding referenceReceiver = (ReferenceBinding) receiverType; - // record a best guess, for clients who need hint about possible contructor match - int length = this.arguments == null ? 0 : this.arguments.length; - TypeBinding[] pseudoArgs = new TypeBinding[length]; - for (int i = length; --i >= 0;) { - pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type - } - this.binding = scope.findMethod(referenceReceiver, TypeConstants.INIT, pseudoArgs, this); - if (this.binding != null && !this.binding.isValidBinding()) { - MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; - // record the closest match, for clients who may still need hint about possible method match - if (closestMatch != null) { - if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method - // shouldn't return generic method outside its context, rather convert it to raw method (175409) - closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null); - } - this.binding = closestMatch; - MethodBinding closestMatchOriginal = closestMatch.original(); - if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) { - // ignore cases where method is used from within inside itself (e.g. direct recursions) - closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + if (receiverType.isValidBinding()) { + // record a best guess, for clients who need hint about possible contructor match + int length = this.arguments == null ? 0 : this.arguments.length; + TypeBinding[] pseudoArgs = new TypeBinding[length]; + for (int i = length; --i >= 0;) { + pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type + } + this.binding = scope.findMethod(referenceReceiver, TypeConstants.INIT, pseudoArgs, this); + if (this.binding != null && !this.binding.isValidBinding()) { + MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; + // record the closest match, for clients who may still need hint about possible method match + if (closestMatch != null) { + if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method + // shouldn't return generic method outside its context, rather convert it to raw method (175409) + closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null); + } + this.binding = closestMatch; + MethodBinding closestMatchOriginal = closestMatch.original(); + if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) { + // ignore cases where method is used from within inside itself (e.g. direct recursions) + closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + } } } + } else { + return null; } if (this.anonymousType != null) { // insert anonymous type in scope (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070) @@ -366,6 +379,10 @@ if (this.binding.declaringClass == null) { this.binding.declaringClass = allocationType; } + if (this.type != null && !this.type.resolvedType.isValidBinding()) { + // problem already got signaled on type reference, do not report secondary problem + return null; + } scope.problemReporter().invalidConstructor(this, this.binding); return this.resolvedType = receiverType; } @@ -383,7 +400,7 @@ } ReferenceBinding superType = (ReferenceBinding) receiverType; if (superType.isTypeVariable()) { - superType = new ProblemReferenceBinding(superType.sourceName(), superType, ProblemReasons.IllegalSuperTypeVariable); + superType = new ProblemReferenceBinding(superType.compoundName, superType, ProblemReasons.IllegalSuperTypeVariable); scope.problemReporter().invalidType(this, superType); return null; } else if (this.type != null && superType.isEnum()) { // tolerate enum constant body @@ -407,6 +424,10 @@ if (inheritedBinding.declaringClass == null) { inheritedBinding.declaringClass = anonymousSuperclass; } + if (this.type != null && !this.type.resolvedType.isValidBinding()) { + // problem already got signaled on type reference, do not report secondary problem + return null; + } scope.problemReporter().invalidConstructor(this, inheritedBinding); return this.resolvedType; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v retrieving revision 1.60 diff -u -r1.60 Annotation.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 21 Nov 2007 17:54:33 -0000 1.60 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 28 Nov 2007 18:11:34 -0000 @@ -235,7 +235,9 @@ this.resolvedType = typeBinding; // ensure type refers to an annotation type if (!typeBinding.isAnnotationType()) { - scope.problemReporter().typeMismatchError(typeBinding, scope.getJavaLangAnnotationAnnotation(), this.type); + if (typeBinding.isValidBinding()) { + scope.problemReporter().typeMismatchError(typeBinding, scope.getJavaLangAnnotationAnnotation(), this.type); + } return null; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java,v retrieving revision 1.70 diff -u -r1.70 SwitchStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 21 Nov 2006 15:42:02 -0000 1.70 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 28 Nov 2007 18:11:37 -0000 @@ -273,7 +273,10 @@ if (expressionType != null) { expression.computeConversion(upperScope, expressionType, expressionType); checkType: { - if (expressionType.isBaseType()) { + if (!expressionType.isValidBinding()) { + expressionType = null; // fault-tolerance: ignore type mismatch from constants from hereon + break checkType; + } else if (expressionType.isBaseType()) { if (expression.isConstantValueOfTypeAssignableToType(expressionType, TypeBinding.INT)) break checkType; if (expressionType.isCompatibleWith(TypeBinding.INT)) Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java,v retrieving revision 1.18 diff -u -r1.18 JavadocQualifiedTypeReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java 10 Apr 2007 19:03:10 -0000 1.18 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java 28 Nov 2007 18:11:35 -0000 @@ -62,22 +62,32 @@ if (this.resolvedType != null) // is a shared type reference which was already resolved return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error - this.resolvedType = getTypeBinding(scope); - if (!this.resolvedType.isValidBinding()) { + boolean hasError = false; + TypeBinding type = this.resolvedType = getTypeBinding(scope); + if (!type.isValidBinding()) { Binding binding = scope.getTypeOrPackage(this.tokens); if (binding instanceof PackageBinding) { this.packageBinding = (PackageBinding) binding; + return null; } else { + hasError = true; reportInvalidType(scope); + type = type.closestMatch(); + if (type == null) { + return null; + } } - return null; } - if (isTypeUseDeprecated(this.resolvedType, scope)) - reportDeprecatedType(this.resolvedType, scope); - if (this.resolvedType instanceof ParameterizedTypeBinding) { - this.resolvedType = ((ParameterizedTypeBinding)this.resolvedType).genericType(); + if (isTypeUseDeprecated(type, scope)) + reportDeprecatedType(type, scope); + if (type instanceof ParameterizedTypeBinding) { + type = ((ParameterizedTypeBinding)this.resolvedType).genericType(); } - return this.resolvedType; + if (hasError) { + // do not store the computed type, keep the problem type instead + return type; + } + return this.resolvedType = type; } public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v retrieving revision 1.62 diff -u -r1.62 ExplicitConstructorCall.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 2 Nov 2007 11:23:38 -0000 1.62 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 28 Nov 2007 18:11:34 -0000 @@ -12,9 +12,25 @@ import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.eclipse.jdt.internal.compiler.codegen.*; -import org.eclipse.jdt.internal.compiler.flow.*; -import org.eclipse.jdt.internal.compiler.lookup.*; +import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.flow.FlowContext; +import org.eclipse.jdt.internal.compiler.flow.FlowInfo; +import org.eclipse.jdt.internal.compiler.lookup.Binding; +import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; +import org.eclipse.jdt.internal.compiler.lookup.InvocationSite; +import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.MethodScope; +import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; +import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.TagBits; +import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; +import org.eclipse.jdt.internal.compiler.lookup.TypeIds; +import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; public class ExplicitConstructorCall extends Statement implements InvocationSite { @@ -40,39 +56,35 @@ this.accessMode = accessMode; } - public FlowInfo analyseCode( - BlockScope currentScope, - FlowContext flowContext, - FlowInfo flowInfo) { - + public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // must verify that exceptions potentially thrown by this expression are caught in the method. try { ((MethodScope) currentScope).isConstructorCall = true; // process enclosing instance - if (qualification != null) { + if (this.qualification != null) { flowInfo = - qualification + this.qualification .analyseCode(currentScope, flowContext, flowInfo) .unconditionalInits(); } // process arguments - if (arguments != null) { - for (int i = 0, max = arguments.length; i < max; i++) { + if (this.arguments != null) { + for (int i = 0, max = this.arguments.length; i < max; i++) { flowInfo = - arguments[i] + this.arguments[i] .analyseCode(currentScope, flowContext, flowInfo) .unconditionalInits(); } } ReferenceBinding[] thrownExceptions; - if ((thrownExceptions = binding.thrownExceptions) != Binding.NO_EXCEPTIONS) { + if ((thrownExceptions = this.binding.thrownExceptions) != Binding.NO_EXCEPTIONS) { // check exceptions flowContext.checkExceptionHandlers( thrownExceptions, - (accessMode == ImplicitSuper) + (this.accessMode == ExplicitConstructorCall.ImplicitSuper) ? (ASTNode) currentScope.methodScope().referenceContext : (ASTNode) this, flowInfo, @@ -93,8 +105,7 @@ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream */ public void generateCode(BlockScope currentScope, CodeStream codeStream) { - - if ((bits & IsReachable) == 0) { + if ((this.bits & ASTNode.IsReachable) == 0) { return; } try { @@ -106,7 +117,7 @@ ReferenceBinding targetType = this.codegenBinding.declaringClass; // special name&ordinal argument generation for enum constructors - if (targetType.erasure().id == T_JavaLangEnum || targetType.isEnum()) { + if (targetType.erasure().id == TypeIds.T_JavaLangEnum || targetType.isEnum()) { codeStream.aload_1(); // pass along name param as name arg codeStream.iload_2(); // pass along ordinal param as ordinal arg } @@ -116,11 +127,11 @@ codeStream.generateSyntheticEnclosingInstanceValues( currentScope, targetType, - (this.bits & ASTNode.DiscardEnclosingInstance) != 0 ? null : qualification, + (this.bits & ASTNode.DiscardEnclosingInstance) != 0 ? null : this.qualification, this); } // generate arguments - generateArguments(binding, arguments, currentScope, codeStream); + generateArguments(this.binding, this.arguments, currentScope, codeStream); // handling innerclass instance allocation - outer local arguments if (targetType.isNestedType()) { @@ -129,15 +140,15 @@ targetType, this); } - if (syntheticAccessor != null) { + if (this.syntheticAccessor != null) { // synthetic accessor got some extra arguments appended to its signature, which need values for (int i = 0, - max = syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; + max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; i < max; i++) { codeStream.aconst_null(); } - codeStream.invokespecial(syntheticAccessor); + codeStream.invokespecial(this.syntheticAccessor); } else { codeStream.invokespecial(this.codegenBinding); } @@ -146,25 +157,23 @@ ((MethodScope) currentScope).isConstructorCall = false; } } + /** * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments() */ public TypeBinding[] genericTypeArguments() { return this.genericTypeArguments; } + public boolean isImplicitSuper() { - //return true if I'm of these compiler added statement super(); - - return (accessMode == ImplicitSuper); + return (this.accessMode == ExplicitConstructorCall.ImplicitSuper); } public boolean isSuperAccess() { - - return accessMode != This; + return this.accessMode != ExplicitConstructorCall.This; } public boolean isTypeAccess() { - return true; } @@ -176,7 +185,7 @@ * exact need. */ void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { - ReferenceBinding superTypeErasure = (ReferenceBinding) binding.declaringClass.erasure(); + ReferenceBinding superTypeErasure = (ReferenceBinding) this.binding.declaringClass.erasure(); if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { // perform some emulation work in case there is some and we are inside a local type only @@ -184,59 +193,57 @@ && currentScope.enclosingSourceType().isLocalType()) { if (superTypeErasure.isLocalType()) { - ((LocalTypeBinding) superTypeErasure).addInnerEmulationDependent(currentScope, qualification != null); + ((LocalTypeBinding) superTypeErasure).addInnerEmulationDependent(currentScope, this.qualification != null); } else { // locally propagate, since we already now the desired shape for sure - currentScope.propagateInnerEmulation(superTypeErasure, qualification != null); + currentScope.propagateInnerEmulation(superTypeErasure, this.qualification != null); } } } } public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { - // if constructor from parameterized type got found, use the original constructor at codegen time - this.codegenBinding = this.binding.original(); - - // perform some emulation work in case there is some and we are inside a local type only - if (binding.isPrivate() && accessMode != This) { - ReferenceBinding declaringClass = this.codegenBinding.declaringClass; - // from 1.4 on, local type constructor can lose their private flag to ease emulation - if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { - // constructor will not be dumped as private, no emulation required thus - this.codegenBinding.tagBits |= TagBits.ClearPrivateModifier; - } else { - syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(this.codegenBinding, isSuperAccess()); - currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this); + // if constructor from parameterized type got found, use the original constructor at codegen time + this.codegenBinding = this.binding.original(); + + // perform some emulation work in case there is some and we are inside a local type only + if (this.binding.isPrivate() && this.accessMode != ExplicitConstructorCall.This) { + ReferenceBinding declaringClass = this.codegenBinding.declaringClass; + // from 1.4 on, local type constructor can lose their private flag to ease emulation + if ((declaringClass.tagBits & TagBits.IsLocalType) != 0 && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { + // constructor will not be dumped as private, no emulation required thus + this.codegenBinding.tagBits |= TagBits.ClearPrivateModifier; + } else { + this.syntheticAccessor = ((SourceTypeBinding) declaringClass).addSyntheticMethod(this.codegenBinding, isSuperAccess()); + currentScope.problemReporter().needToEmulateMethodAccess(this.codegenBinding, this); + } } } - } } public StringBuffer printStatement(int indent, StringBuffer output) { - printIndent(indent, output); - if (qualification != null) qualification.printExpression(0, output).append('.'); - if (typeArguments != null) { + if (this.qualification != null) this.qualification.printExpression(0, output).append('.'); + if (this.typeArguments != null) { output.append('<'); - int max = typeArguments.length - 1; + int max = this.typeArguments.length - 1; for (int j = 0; j < max; j++) { - typeArguments[j].print(0, output); + this.typeArguments[j].print(0, output); output.append(", ");//$NON-NLS-1$ } - typeArguments[max].print(0, output); + this.typeArguments[max].print(0, output); output.append('>'); } - if (accessMode == This) { + if (this.accessMode == ExplicitConstructorCall.This) { output.append("this("); //$NON-NLS-1$ } else { output.append("super("); //$NON-NLS-1$ } - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { + if (this.arguments != null) { + for (int i = 0; i < this.arguments.length; i++) { if (i > 0) output.append(", "); //$NON-NLS-1$ - arguments[i].printExpression(0, output); + this.arguments[i].printExpression(0, output); } } return output.append(");"); //$NON-NLS-1$ @@ -273,38 +280,42 @@ } methodScope.isConstructorCall = true; ReferenceBinding receiverType = scope.enclosingReceiverType(); - if (accessMode != This) + boolean rcvHasError = false; + if (this.accessMode != ExplicitConstructorCall.This) { receiverType = receiverType.superclass(); - - if (receiverType == null) { - return; + TypeReference superclassRef = scope.referenceType().superclass; + if (superclassRef != null && superclassRef.resolvedType != null && !superclassRef.resolvedType.isValidBinding()) { + rcvHasError = true; + } } - // prevent (explicit) super constructor invocation from within enum - if (this.accessMode == Super && receiverType.erasure().id == T_JavaLangEnum) { - scope.problemReporter().cannotInvokeSuperConstructorInEnum(this, methodScope.referenceMethod().binding); - } - // qualification should be from the type of the enclosingType - if (qualification != null) { - if (accessMode != Super) { - scope.problemReporter().unnecessaryEnclosingInstanceSpecification( - qualification, - receiverType); - } - ReferenceBinding enclosingType = receiverType.enclosingType(); - if (enclosingType == null) { - scope.problemReporter().unnecessaryEnclosingInstanceSpecification( - qualification, - receiverType); - this.bits |= ASTNode.DiscardEnclosingInstance; - } else { - TypeBinding qTb = qualification.resolveTypeExpecting(scope, enclosingType); - qualification.computeConversion(scope, qTb, qTb); + if (receiverType != null) { + // prevent (explicit) super constructor invocation from within enum + if (this.accessMode == ExplicitConstructorCall.Super && receiverType.erasure().id == TypeIds.T_JavaLangEnum) { + scope.problemReporter().cannotInvokeSuperConstructorInEnum(this, methodScope.referenceMethod().binding); + } + // qualification should be from the type of the enclosingType + if (this.qualification != null) { + if (this.accessMode != ExplicitConstructorCall.Super) { + scope.problemReporter().unnecessaryEnclosingInstanceSpecification( + this.qualification, + receiverType); + } + if (!rcvHasError) { + ReferenceBinding enclosingType = receiverType.enclosingType(); + if (enclosingType == null) { + scope.problemReporter().unnecessaryEnclosingInstanceSpecification(this.qualification, receiverType); + this.bits |= ASTNode.DiscardEnclosingInstance; + } else { + TypeBinding qTb = this.qualification.resolveTypeExpecting(scope, enclosingType); + this.qualification.computeConversion(scope, qTb, qTb); + } + } } } // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { + boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; int length = this.typeArguments.length; - boolean argHasError = false; // typeChecks all arguments this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; @@ -316,21 +327,25 @@ } } if (argHasError) { + if (this.arguments != null) { // still attempt to resolve arguments + for (int i = 0, max = this.arguments.length; i < max; i++) { + this.arguments[i].resolveType(scope); + } + } return; } } - // arguments buffering for the method lookup TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; boolean argsContainCast = false; - if (arguments != null) { + if (this.arguments != null) { boolean argHasError = false; // typeChecks all arguments - int length = arguments.length; + int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++) { Expression argument = this.arguments[i]; if (argument instanceof CastExpression) { - argument.bits |= DisableUnnecessaryCastCheck; // will check later on + argument.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on argsContainCast = true; } if ((argumentTypes[i] = argument.resolveType(scope)) == null) { @@ -338,6 +353,9 @@ } } if (argHasError) { + if (receiverType == null) { + return; + } // record a best guess, for clients who need hint about possible contructor match TypeBinding[] pseudoArgs = new TypeBinding[length]; for (int i = length; --i >= 0;) { @@ -362,24 +380,32 @@ } return; } - } else if (receiverType.erasure().id == T_JavaLangEnum) { + } else if (receiverType.erasure().id == TypeIds.T_JavaLangEnum) { // TODO (philippe) get rid of once well-known binding is available argumentTypes = new TypeBinding[] { scope.getJavaLangString(), TypeBinding.INT }; } - if ((binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) { - if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ImplicitSuper)) - scope.problemReporter().deprecatedMethod(binding, this); - checkInvocationArguments(scope, null, receiverType, binding, this.arguments, argumentTypes, argsContainCast, this); - if (binding.isPrivate() || receiverType.isLocalType()) { - binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + if (receiverType == null) { + return; + } + if ((this.binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) { + if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) { + scope.problemReporter().deprecatedMethod(this.binding, this); + } + checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this); + if (this.binding.isPrivate() || receiverType.isLocalType()) { + this.binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } - if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { + if (this.typeArguments != null + && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); } } else { - if (binding.declaringClass == null) - binding.declaringClass = receiverType; - scope.problemReporter().invalidConstructor(this, binding); + if (this.binding.declaringClass == null) { + this.binding.declaringClass = receiverType; + } + if (rcvHasError) + return; // avoid secondary errors + scope.problemReporter().invalidConstructor(this, this.binding); } } finally { methodScope.isConstructorCall = false; @@ -399,7 +425,6 @@ } public void traverse(ASTVisitor visitor, BlockScope scope) { - if (visitor.visit(this, scope)) { if (this.qualification != null) { this.qualification.traverse(visitor, scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.126 diff -u -r1.126 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 9 Nov 2007 08:42:33 -0000 1.126 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 28 Nov 2007 18:11:35 -0000 @@ -353,7 +353,7 @@ // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = false; // typeChecks all arguments + boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; // typeChecks all arguments this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; @@ -365,6 +365,11 @@ } } if (argHasError) { + if (this.arguments != null) { // still attempt to resolve arguments + for (int i = 0, max = this.arguments.length; i < max; i++) { + this.arguments[i].resolveType(scope); + } + } return null; } } @@ -435,6 +440,10 @@ return null; } } + if (!this.receiver.resolvedType.isValidBinding()) { + // problem already got signaled on receiver, do not report secondary problem + return null; + } scope.problemReporter().invalidMethod(this, this.binding); MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; switch (this.binding.problemId()) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v retrieving revision 1.120 diff -u -r1.120 QualifiedNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 9 Nov 2007 08:42:33 -0000 1.120 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 28 Nov 2007 18:11:36 -0000 @@ -25,6 +25,7 @@ import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.eclipse.jdt.internal.compiler.lookup.MethodScope; +import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; @@ -980,7 +981,7 @@ public TypeBinding reportError(BlockScope scope) { if (this.binding instanceof ProblemFieldBinding) { scope.problemReporter().invalidField(this, (FieldBinding) this.binding); - } else if (this.binding instanceof ProblemReferenceBinding) { + } else if (this.binding instanceof ProblemReferenceBinding || this.binding instanceof MissingTypeBinding) { scope.problemReporter().invalidType(this, (TypeBinding) this.binding); } else { scope.problemReporter().unresolvableReference(this, this.binding); Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v retrieving revision 1.155 diff -u -r1.155 ClassScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 21 Nov 2007 14:15:23 -0000 1.155 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 28 Nov 2007 18:11:38 -0000 @@ -858,13 +858,19 @@ ReferenceBinding superclass = findSupertype(superclassRef); if (superclass != null) { // is null if a cycle was detected cycle or a problem if (!superclass.isClass()) { - problemReporter().superclassMustBeAClass(sourceType, superclassRef, superclass); + if (superclass.isValidBinding()) { + problemReporter().superclassMustBeAClass(sourceType, superclassRef, superclass); + } } else if (superclass.isFinal()) { problemReporter().classExtendFinalClass(sourceType, superclassRef, superclass); } else if ((superclass.tagBits & TagBits.HasDirectWildcard) != 0) { problemReporter().superTypeCannotUseWildcard(sourceType, superclassRef, superclass); } else if (superclass.erasure().id == T_JavaLangEnum) { problemReporter().cannotExtendEnum(sourceType, superclassRef, superclass); + } else if ((superclass.tagBits & TagBits.HierarchyHasProblems) != 0) { + sourceType.superclass = superclass; + sourceType.tagBits |= TagBits.HierarchyHasProblems; // propagate if missing supertype + return superclassRef.resolvedType.isValidBinding(); // reported some error against the source type ? } else { // only want to reach here when no errors are reported sourceType.superclass = superclass; @@ -888,7 +894,7 @@ // arity check for well-known Enum TypeVariableBinding[] refTypeVariables = rootEnumType.typeVariables(); if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic - problemReporter().nonGenericTypeCannotBeParameterized(null, rootEnumType, new TypeBinding[]{ sourceType }); + problemReporter().nonGenericTypeCannotBeParameterized(0, null, rootEnumType, new TypeBinding[]{ sourceType }); return false; // cannot reach here as AbortCompilation is thrown } else if (1 != refTypeVariables.length) { // check arity problemReporter().incorrectArityForParameterizedType(null, rootEnumType, new TypeBinding[]{ sourceType }); @@ -896,6 +902,7 @@ } // check argument type compatibility ParameterizedTypeBinding superType = environment().createParameterizedType(rootEnumType, new TypeBinding[]{ environment().convertToRawType(sourceType) } , null); + sourceType.tagBits |= (superType.tagBits & TagBits.HierarchyHasProblems); // propagate if missing supertpye sourceType.superclass = superType; // bound check (in case of bogus definition of Enum type) if (refTypeVariables[0].boundCheck(superType, sourceType) != TypeConstants.OK) { @@ -947,14 +954,18 @@ for (int j = 0; j < i; j++) { if (interfaceBindings[j] == superInterface) { problemReporter().duplicateSuperinterface(sourceType, superInterfaceRef, superInterface); + sourceType.tagBits |= TagBits.HierarchyHasProblems; + noProblems = false; continue nextInterface; } } if (!superInterface.isInterface()) { - problemReporter().superinterfaceMustBeAnInterface(sourceType, superInterfaceRef, superInterface); - sourceType.tagBits |= TagBits.HierarchyHasProblems; - noProblems = false; - continue nextInterface; + if (superInterface.isValidBinding()) { + problemReporter().superinterfaceMustBeAnInterface(sourceType, superInterfaceRef, superInterface); + sourceType.tagBits |= TagBits.HierarchyHasProblems; + noProblems = false; + continue nextInterface; + } } else if (superInterface.isAnnotationType()){ problemReporter().annotationTypeUsedAsSuperinterface(sourceType, superInterfaceRef, superInterface); } @@ -964,6 +975,13 @@ noProblems = false; continue nextInterface; } + if ((superInterface.tagBits & TagBits.HierarchyHasProblems) != 0) { + sourceType.tagBits |= TagBits.HierarchyHasProblems; // propagate if missing supertype + if (!superInterfaceRef.resolvedType.isValidBinding()) { + // reported some error against the source type ? + noProblems = false; + } + } // only want to reach here when no errors are reported interfaceBindings[count++] = superInterface; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v retrieving revision 1.110 diff -u -r1.110 CompilationUnitScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 24 Sep 2007 22:49:54 -0000 1.110 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 28 Nov 2007 18:11:39 -0000 @@ -562,7 +562,11 @@ if (importBinding == null || !importBinding.isValidBinding()) { // create a proxy for the missing BinaryType - BinaryTypeBinding missingObject = environment.cacheMissingBinaryType(JAVA_LANG_OBJECT, this.referenceContext); + problemReporter().isClassPathCorrect( + JAVA_LANG_OBJECT, + this.referenceContext, + environment.missingClassFileLocation); + BinaryTypeBinding missingObject = environment.createMissingType(null, JAVA_LANG_OBJECT); importBinding = missingObject.fPackage; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java,v retrieving revision 1.42 diff -u -r1.42 PackageBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java 6 Mar 2007 02:38:50 -0000 1.42 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java 28 Nov 2007 18:11:39 -0000 @@ -135,7 +135,7 @@ typeBinding = BinaryTypeBinding.resolveType(typeBinding, environment, false); // no raw conversion for now if (typeBinding.isNestedType()) - return new ProblemReferenceBinding(name, typeBinding, ProblemReasons.InternalNameProvided); + return new ProblemReferenceBinding(new char[][]{ name }, typeBinding, ProblemReasons.InternalNameProvided); return typeBinding; } /* Answer the type named name if it exists in the cache. @@ -166,7 +166,7 @@ if (typeBinding != null && typeBinding != LookupEnvironment.TheNotFoundType) { typeBinding = BinaryTypeBinding.resolveType(typeBinding, environment, false); // no raw conversion for now if (typeBinding.isNestedType()) - return new ProblemReferenceBinding(name, typeBinding, ProblemReasons.InternalNameProvided); + return new ProblemReferenceBinding(new char[][]{name}, typeBinding, ProblemReasons.InternalNameProvided); return typeBinding; } @@ -177,7 +177,7 @@ if (typeBinding == null) { // have not looked for it before if ((typeBinding = environment.askForType(this, name)) != null) { if (typeBinding.isNestedType()) - return new ProblemReferenceBinding(name, typeBinding, ProblemReasons.InternalNameProvided); + return new ProblemReferenceBinding(new char[][]{name}, typeBinding, ProblemReasons.InternalNameProvided); return typeBinding; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v retrieving revision 1.115 diff -u -r1.115 ReferenceBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 9 Oct 2007 20:30:15 -0000 1.115 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 28 Nov 2007 18:11:40 -0000 @@ -319,14 +319,6 @@ return invocationType.fPackage == this.fPackage; } -/** - * In case of problems, returns the closest match found. It may not be perfect match, but the - * result of a best effort to improve fault-tolerance. -*/ -public ReferenceBinding closestMatch() { - return this; // by default, the closest match is the binding itself -} - public char[] computeGenericTypeSignature(TypeVariableBinding[] typeVariables) { boolean isMemberOfGeneric = isMemberType() && (enclosingType().modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.320 diff -u -r1.320 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 2 Nov 2007 18:12:33 -0000 1.320 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 28 Nov 2007 18:11:41 -0000 @@ -754,7 +754,7 @@ ? memberType.canBeSeenBy(getCurrentPackage()) : memberType.canBeSeenBy(enclosingType, enclosingReceiverType)) return memberType; - return new ProblemReferenceBinding(typeName, memberType, ProblemReasons.NotVisible); + return new ProblemReferenceBinding(new char[][]{typeName}, memberType, ProblemReasons.NotVisible); } return null; } @@ -948,7 +948,7 @@ ? memberType.canBeSeenBy(currentPackage) : memberType.canBeSeenBy(enclosingType, enclosingSourceType)) return memberType; - return new ProblemReferenceBinding(typeName, memberType, ProblemReasons.NotVisible); + return new ProblemReferenceBinding(new char[][]{typeName}, memberType, ProblemReasons.NotVisible); } // collect all superinterfaces of receiverType until the memberType is found in a supertype @@ -999,7 +999,7 @@ if (visibleMemberType == null) visibleMemberType = memberType; else - return new ProblemReferenceBinding(typeName, visibleMemberType, ProblemReasons.Ambiguous); + return new ProblemReferenceBinding(new char[][]{typeName}, visibleMemberType, ProblemReasons.Ambiguous); } else { notVisible = memberType; } @@ -1016,7 +1016,7 @@ if (visibleMemberType == null) { visibleMemberType = memberType; } else { - ambiguous = new ProblemReferenceBinding(typeName, visibleMemberType, ProblemReasons.Ambiguous); + ambiguous = new ProblemReferenceBinding(new char[][]{typeName}, visibleMemberType, ProblemReasons.Ambiguous); break done; } } else { @@ -1040,7 +1040,7 @@ if (visibleMemberType != null) return visibleMemberType; if (notVisible != null) - return new ProblemReferenceBinding(typeName, notVisible, ProblemReasons.NotVisible); + return new ProblemReferenceBinding(new char[][]{typeName}, notVisible, ProblemReasons.NotVisible); return null; } @@ -1369,7 +1369,7 @@ if (typeBinding.isValidBinding()) { if (declarationPackage != invocationPackage && !typeBinding.canBeSeenBy(invocationPackage)) - return new ProblemReferenceBinding(typeName, typeBinding, ProblemReasons.NotVisible); + return new ProblemReferenceBinding(new char[][]{typeName}, typeBinding, ProblemReasons.NotVisible); } return typeBinding; } @@ -1589,7 +1589,11 @@ } if (foundInImport) // Answer error binding -- import on demand conflict; name found in two import on demand packages. - return new ProblemReferenceBinding(name, null, ProblemReasons.Ambiguous); + return new ProblemFieldBinding( + foundField, // closest match + foundField.declaringClass, + name, + ProblemReasons.Ambiguous); foundField = temp; foundInImport = true; } @@ -2047,7 +2051,9 @@ public final ReferenceBinding getMemberType(char[] typeName, ReferenceBinding enclosingType) { ReferenceBinding memberType = findMemberType(typeName, enclosingType); if (memberType != null) return memberType; - return new ProblemReferenceBinding(typeName, null, ProblemReasons.NotFound); + char[][] compoundName = new char[][] { typeName }; + ReferenceBinding missingType = environment().createMissingType(compilationUnitScope().getCurrentPackage(), compoundName); + return new ProblemReferenceBinding(compoundName, missingType, ProblemReasons.NotFound); } public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { @@ -2103,8 +2109,10 @@ public final Binding getPackage(char[][] compoundName) { compilationUnitScope().recordQualifiedReference(compoundName); Binding binding = getTypeOrPackage(compoundName[0], Binding.TYPE | Binding.PACKAGE); - if (binding == null) - return new ProblemReferenceBinding(compoundName[0], null, ProblemReasons.NotFound); + if (binding == null) { + char[][] qName = new char[][] { compoundName[0] }; + return new ProblemReferenceBinding(qName, environment().createMissingType(compilationUnitScope().getCurrentPackage(), qName), ProblemReasons.NotFound); + } if (!binding.isValidBinding()) return binding; @@ -2114,21 +2122,20 @@ PackageBinding packageBinding = (PackageBinding) binding; while (currentIndex < compoundName.length) { binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]); - if (binding == null) - return new ProblemReferenceBinding( - CharOperation.subarray(compoundName, 0, currentIndex), - null, - ProblemReasons.NotFound); + if (binding == null) { + char[][] qName = CharOperation.subarray(compoundName, 0, currentIndex); + return new ProblemReferenceBinding(qName, environment().createMissingType(packageBinding, qName), ProblemReasons.NotFound); + } if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, + binding instanceof ReferenceBinding ? (ReferenceBinding)((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) return packageBinding; packageBinding = (PackageBinding) binding; } - return new ProblemReferenceBinding(compoundName, null, ProblemReasons.NotFound); + return new ProblemReferenceBinding(compoundName, environment().createMissingType(null, compoundName), ProblemReasons.NotFound); } /* Answer the type binding that corresponds the given name, starting the lookup in the receiver. @@ -2161,7 +2168,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.arrayConcat(packageBinding.compoundName, name), - binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, + binding instanceof ReferenceBinding ? (ReferenceBinding)((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); ReferenceBinding typeBinding = (ReferenceBinding) binding; @@ -2187,10 +2194,11 @@ CompilationUnitScope unitScope = compilationUnitScope(); unitScope.recordQualifiedReference(compoundName); - Binding binding = - getTypeOrPackage(compoundName[0], typeNameLength == 1 ? Binding.TYPE : Binding.TYPE | Binding.PACKAGE); - if (binding == null) - return new ProblemReferenceBinding(compoundName[0], null, ProblemReasons.NotFound); + Binding binding = getTypeOrPackage(compoundName[0], typeNameLength == 1 ? Binding.TYPE : Binding.TYPE | Binding.PACKAGE); + if (binding == null) { + char[][] qName = new char[][] { compoundName[0] }; + return new ProblemReferenceBinding(qName, environment().createMissingType(compilationUnitScope().getCurrentPackage(), qName), ProblemReasons.NotFound); + } if (!binding.isValidBinding()) return (ReferenceBinding) binding; @@ -2200,25 +2208,29 @@ PackageBinding packageBinding = (PackageBinding) binding; while (currentIndex < typeNameLength) { binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]); // does not check visibility - if (binding == null) + if (binding == null) { + char[][] qName = CharOperation.subarray(compoundName, 0, currentIndex); return new ProblemReferenceBinding( - CharOperation.subarray(compoundName, 0, currentIndex), - null, + qName, + environment().createMissingType(packageBinding, qName), ProblemReasons.NotFound); + } if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, + binding instanceof ReferenceBinding ? (ReferenceBinding)((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) break; packageBinding = (PackageBinding) binding; } - if (binding instanceof PackageBinding) + if (binding instanceof PackageBinding) { + char[][] qName = CharOperation.subarray(compoundName, 0, currentIndex); return new ProblemReferenceBinding( - CharOperation.subarray(compoundName, 0, currentIndex), - null, + qName, + environment().createMissingType(null, qName), ProblemReasons.NotFound); + } checkVisibility = true; } @@ -2239,12 +2251,12 @@ ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) typeBinding; return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - problemBinding.closestMatch(), + problemBinding.closestReferenceMatch(), typeBinding.problemId()); } return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), typeBinding.problemId()); } } @@ -2288,7 +2300,7 @@ ReferenceBinding localType = ((BlockScope) scope).findLocalType(name); // looks in this scope only if (localType != null) { if (foundType != null && foundType != localType) - return new ProblemReferenceBinding(name, foundType, ProblemReasons.InheritedNameHidesEnclosingName); + return new ProblemReferenceBinding(new char[][]{name}, foundType, ProblemReasons.InheritedNameHidesEnclosingName); return localType; } break; @@ -2315,19 +2327,19 @@ // supercedes any potential InheritedNameHidesEnclosingName problem return memberType; // make the user qualify the type, likely wants the first inherited type - return new ProblemReferenceBinding(name, foundType, ProblemReasons.InheritedNameHidesEnclosingName); + return new ProblemReferenceBinding(new char[][]{name}, foundType, ProblemReasons.InheritedNameHidesEnclosingName); } if (memberType.isValidBinding()) { if (sourceType == memberType.enclosingType() || compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { if (insideStaticContext && !memberType.isStatic() && sourceType.isGenericType()) - return new ProblemReferenceBinding(name, memberType, ProblemReasons.NonStaticReferenceInStaticContext); + return new ProblemReferenceBinding(new char[][]{name}, memberType, ProblemReasons.NonStaticReferenceInStaticContext); // found a valid type in the 'immediate' scope (ie. not inherited) // OR in 1.4 mode (inherited shadows enclosing) if (foundType == null) return memberType; // if a valid type was found, complain when another is found in an 'immediate' enclosing type (ie. not inherited) if (foundType.isValidBinding() && foundType != memberType) - return new ProblemReferenceBinding(name, foundType, ProblemReasons.InheritedNameHidesEnclosingName); + return new ProblemReferenceBinding(new char[][]{name}, foundType, ProblemReasons.InheritedNameHidesEnclosingName); } } if (foundType == null || (foundType.problemId() == ProblemReasons.NotVisible && memberType.problemId() != ProblemReasons.NotVisible)) @@ -2338,14 +2350,14 @@ TypeVariableBinding typeVariable = sourceType.getTypeVariable(name); if (typeVariable != null) { if (insideStaticContext) // do not consider this type modifiers: access is legite within same type - return new ProblemReferenceBinding(name, typeVariable, ProblemReasons.NonStaticReferenceInStaticContext); + return new ProblemReferenceBinding(new char[][]{name}, typeVariable, ProblemReasons.NonStaticReferenceInStaticContext); return typeVariable; } insideStaticContext |= sourceType.isStatic(); insideTypeAnnotation = false; if (CharOperation.equals(sourceType.sourceName, name)) { if (foundType != null && foundType != sourceType && foundType.problemId() != ProblemReasons.NotVisible) - return new ProblemReferenceBinding(name, foundType, ProblemReasons.InheritedNameHidesEnclosingName); + return new ProblemReferenceBinding(new char[][]{name}, foundType, ProblemReasons.InheritedNameHidesEnclosingName); return sourceType; } break; @@ -2446,7 +2458,7 @@ } if (foundInImport) { // Answer error binding -- import on demand conflict; name found in two import on demand packages. - temp = new ProblemReferenceBinding(name, type, ProblemReasons.Ambiguous); + temp = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.Ambiguous); if (typeOrPackageCache != null) typeOrPackageCache.put(name, temp); return temp; @@ -2479,7 +2491,8 @@ // Answer error binding -- could not find name if (foundType == null) { - foundType = new ProblemReferenceBinding(name, null, ProblemReasons.NotFound); + char[][] qName = new char[][] { name }; + foundType = new ProblemReferenceBinding(qName, environment().createMissingType(unitScope.fPackage, qName), ProblemReasons.NotFound); if (typeOrPackageCache != null && (mask & Binding.PACKAGE) != 0) // only put NotFound type in cache if you know its not a package typeOrPackageCache.put(name, foundType); } @@ -2514,7 +2527,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - binding instanceof ReferenceBinding ? ((ReferenceBinding)binding).closestMatch() : null, + binding instanceof ReferenceBinding ? (ReferenceBinding)((ReferenceBinding)binding).closestMatch() : null, binding.problemId()); if (!(binding instanceof PackageBinding)) break; @@ -2540,7 +2553,7 @@ if (!typeBinding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)typeBinding.closestMatch(), typeBinding.problemId()); if (typeBinding.isGenericType()) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java,v retrieving revision 1.18 diff -u -r1.18 ProblemReferenceBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java 20 Oct 2006 11:02:03 -0000 1.18 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java 28 Nov 2007 18:11:40 -0000 @@ -21,14 +21,18 @@ this.closestMatch = closestMatch; this.problemReason = problemReason; } -public ProblemReferenceBinding(char[] name, ReferenceBinding closestMatch, int problemReason) { - this(new char[][] {name}, closestMatch, problemReason); + +/** + * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#closestMatch() + */ +public TypeBinding closestMatch() { + return this.closestMatch; } /** - * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#closestMatch() + * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#closestMatch() */ -public ReferenceBinding closestMatch() { +public ReferenceBinding closestReferenceMatch() { return this.closestMatch; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java =================================================================== RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java 22 Dec 2006 16:02:08 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jdt.internal.compiler.lookup; - -import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; - -public class MissingBinaryTypeBinding extends BinaryTypeBinding { - -/** - * Special constructor for constructing proxies of missing binary types (114349) - * @param packageBinding - * @param compoundName - * @param environment - */ -public MissingBinaryTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) { - this.compoundName = compoundName; - computeId(); - this.tagBits |= TagBits.IsBinaryBinding | TagBits.HierarchyHasProblems; - this.environment = environment; - this.fPackage = packageBinding; - this.fileName = CharOperation.concatWith(compoundName, '/'); - this.sourceName = compoundName[compoundName.length - 1]; // [java][util][Map$Entry] - this.modifiers = ClassFileConstants.AccPublic; - this.superclass = null; // will be fixed up using #setMissingSuperclass(...) - this.superInterfaces = Binding.NO_SUPERINTERFACES; - this.typeVariables = Binding.NO_TYPE_VARIABLES; - this.memberTypes = Binding.NO_MEMBER_TYPES; - this.fields = Binding.NO_FIELDS; - this.methods = Binding.NO_METHODS; -} - -/** - * Missing binary type will answer false to #isValidBinding() - * @see org.eclipse.jdt.internal.compiler.lookup.Binding#problemId() - */ -public int problemId() { - return ProblemReasons.NotFound; -} - -/** - * Only used to fixup the superclass hierarchy of proxy binary types - * @param missingSuperclass - * @see LookupEnvironment#cacheMissingBinaryType(char[][], CompilationUnitDeclaration) - */ -void setMissingSuperclass(ReferenceBinding missingSuperclass) { - this.superclass = missingSuperclass; -} -} Index: compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java,v retrieving revision 1.64 diff -u -r1.64 WildcardBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 24 Sep 2007 22:49:54 -0000 1.64 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java 28 Nov 2007 18:11:41 -0000 @@ -404,7 +404,7 @@ this.fPackage = someGenericType.getPackage(); } if (someBound != null) { - this.tagBits |= someBound.tagBits & TagBits.HasTypeVariable; + this.tagBits |= someBound.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType); } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v retrieving revision 1.108 diff -u -r1.108 BlockScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 24 Sep 2007 22:49:54 -0000 1.108 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 28 Nov 2007 18:11:38 -0000 @@ -436,7 +436,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!((ReferenceBinding) binding).canBeSeenBy(this)) return new ProblemReferenceBinding( @@ -495,7 +495,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (invocationSite instanceof ASTNode) { referenceBinding = (ReferenceBinding) binding; @@ -560,7 +560,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!((ReferenceBinding) binding).canBeSeenBy(this)) return new ProblemReferenceBinding( @@ -602,7 +602,7 @@ if (!binding.isValidBinding()) { return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v retrieving revision 1.99 diff -u -r1.99 ParameterizedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 9 Oct 2007 20:30:15 -0000 1.99 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 28 Nov 2007 18:11:40 -0000 @@ -612,7 +612,7 @@ this.modifiers |= ExtraCompilerModifiers.AccGenericSignature; } else if (this.enclosingType != null) { this.modifiers |= (this.enclosingType.modifiers & ExtraCompilerModifiers.AccGenericSignature); - this.tagBits |= this.enclosingType.tagBits & TagBits.HasTypeVariable; + this.tagBits |= this.enclosingType.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType); } if (someArguments != null) { this.arguments = someArguments; @@ -632,10 +632,10 @@ this.tagBits |= TagBits.IsBoundParameterizedType; break; } - this.tagBits |= someArgument.tagBits & TagBits.HasTypeVariable; + this.tagBits |= someArgument.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType); } } - this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType); + this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType | TagBits.HasMissingType); this.tagBits &= ~(TagBits.AreFieldsComplete|TagBits.AreMethodsComplete); } @@ -807,7 +807,7 @@ // arity check TypeVariableBinding[] refTypeVariables = resolvedType.typeVariables(); if (refTypeVariables == Binding.NO_TYPE_VARIABLES) { // check generic - this.environment.problemReporter.nonGenericTypeCannotBeParameterized(null, resolvedType, this.arguments); + this.environment.problemReporter.nonGenericTypeCannotBeParameterized(0, null, resolvedType, this.arguments); return this; // cannot reach here as AbortCompilation is thrown } else if (argLength != refTypeVariables.length) { // check arity this.environment.problemReporter.incorrectArityForParameterizedType(null, resolvedType, this.arguments); Index: compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java,v retrieving revision 1.29 diff -u -r1.29 UnresolvedReferenceBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java 27 Apr 2007 15:51:39 -0000 1.29 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java 28 Nov 2007 18:11:41 -0000 @@ -45,11 +45,17 @@ ReferenceBinding targetType = this.resolvedType; if (targetType == null) { targetType = this.fPackage.getType0(this.compoundName[this.compoundName.length - 1]); - if (targetType == this) + if (targetType == this) { targetType = environment.askForType(this.compoundName); + } if (targetType == null || targetType == this) { // could not resolve any better, error was already reported against it + // report the missing class file first + environment.problemReporter.isClassPathCorrect( + this.compoundName, + environment.unitBeingCompleted, + environment.missingClassFileLocation); // create a proxy for the missing BinaryType - targetType = environment.cacheMissingBinaryType(this.compoundName, null); + targetType = environment.createMissingType(null, this.compoundName); } setResolvedType(targetType, environment); } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v retrieving revision 1.108 diff -u -r1.108 BinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 6 Nov 2007 08:39:06 -0000 1.108 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 28 Nov 2007 18:11:38 -0000 @@ -168,7 +168,7 @@ this.sourceName = binaryType.getSourceName(); this.modifiers = binaryType.getModifiers(); - if ((binaryType.getTagBits() & TagBits.HasInconsistentHierarchy) != 0) + if ((binaryType.getTagBits() & TagBits.HierarchyHasProblems) != 0) this.tagBits |= TagBits.HierarchyHasProblems; if (binaryType.isAnonymous()) { 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.31 diff -u -r1.31 TagBits.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 6 Mar 2007 02:38:51 -0000 1.31 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 28 Nov 2007 18:11:41 -0000 @@ -26,7 +26,8 @@ long AnonymousTypeMask = LocalTypeMask | IsAnonymousType; long IsBinaryBinding = ASTNode.Bit7; - long HasInconsistentHierarchy = ASTNode.Bit8; // for binary type binding only + // set for all bindings either denoting a missing type, or indirectly referencing some missing type + long HasMissingType = ASTNode.Bit8; // for the type cycle hierarchy check used by ClassScope long BeginHierarchyCheck = ASTNode.Bit9; // type 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.151 diff -u -r1.151 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 28 Sep 2007 18:26:06 -0000 1.151 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 28 Nov 2007 18:11:41 -0000 @@ -1272,8 +1272,7 @@ try { initializationScope.initializedField = field; FieldDeclaration fieldDecl = fieldDecls[f]; - TypeBinding fieldType = - fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT + TypeBinding fieldType = fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT ? initializationScope.environment().convertToRawType(this) // enum constant is implicitly of declaring enum type : fieldDecl.type.resolveType(initializationScope, true /* check bounds*/); field.type = fieldType; @@ -1292,6 +1291,7 @@ fieldDecl.binding = null; return null; } + field.tagBits |= (fieldType.tagBits & TagBits.HasMissingType); TypeBinding leafType = fieldType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding)leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) { field.modifiers |= ExtraCompilerModifiers.AccGenericSignature; @@ -1341,11 +1341,13 @@ continue; } if (resolvedExceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) { - methodDecl.scope.problemReporter().cannotThrowType(exceptionTypes[i], resolvedExceptionType); - continue; + if (resolvedExceptionType.isValidBinding()) { + methodDecl.scope.problemReporter().cannotThrowType(exceptionTypes[i], resolvedExceptionType); + continue; + } } - if ((resolvedExceptionType.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) - method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; + method.tagBits |= (resolvedExceptionType.tagBits & TagBits.HasMissingType); + method.modifiers |= (resolvedExceptionType.modifiers & ExtraCompilerModifiers.AccGenericSignature); method.thrownExceptions[count++] = resolvedExceptionType; } if (count < size) @@ -1367,6 +1369,7 @@ methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg); foundArgProblem = true; } else { + method.tagBits |= (parameterType.tagBits & TagBits.HasMissingType); TypeBinding leafType = parameterType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; @@ -1397,6 +1400,7 @@ methodDecl.scope.problemReporter().returnTypeCannotBeVoidArray((MethodDeclaration) methodDecl); foundReturnTypeProblem = true; } else { + method.tagBits |= (methodType.tagBits & TagBits.HasMissingType); method.returnType = methodType; TypeBinding leafType = methodType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java,v retrieving revision 1.56 diff -u -r1.56 ArrayBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java 24 Sep 2007 22:49:54 -0000 1.56 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java 28 Nov 2007 18:11:37 -0000 @@ -33,9 +33,15 @@ if (type instanceof UnresolvedReferenceBinding) ((UnresolvedReferenceBinding) type).addWrapper(this, environment); else - this.tagBits |= type.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard); + this.tagBits |= type.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard | TagBits.HasMissingType); } +public TypeBinding closestMatch() { + if (this.isValidBinding()) { + return this; + } + return this.environment.createArrayType(this.leafComponentType.closestMatch(), this.dimensions); +} /** * Collect the substitutes into a map for certain type variables inside the receiver type * e.g. Collection.collectSubstitutes(Collection>, Map), will populate Map with: T --> List @@ -241,7 +247,7 @@ public void swapUnresolved(UnresolvedReferenceBinding unresolvedType, ReferenceBinding resolvedType, LookupEnvironment env) { if (this.leafComponentType == unresolvedType) { this.leafComponentType = env.convertUnresolvedBinaryToRawType(resolvedType); - this.tagBits |= this.leafComponentType.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard); + this.tagBits |= this.leafComponentType.tagBits & (TagBits.HasTypeVariable | TagBits.HasDirectWildcard | TagBits.HasMissingType); } } public String toString() { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.89 diff -u -r1.89 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 25 Oct 2007 10:44:09 -0000 1.89 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 28 Nov 2007 18:11:39 -0000 @@ -29,36 +29,28 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants { - final static int BUILD_FIELDS_AND_METHODS = 4; - final static int BUILD_TYPE_HIERARCHY = 1; - final static int CHECK_AND_SET_IMPORTS = 2; - final static int CONNECT_TYPE_HIERARCHY = 3; - static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound); - static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR, null, NotFound); - /** * Map from typeBinding -> accessRestriction rule */ private Map accessRestrictions; ImportBinding[] defaultImports; - public PackageBinding defaultPackage; HashtableOfPackage knownPackages; private int lastCompletedUnitIndex = -1; private int lastUnitIndex = -1; - + public INameEnvironment nameEnvironment; public CompilerOptions globalOptions; - public ProblemReporter problemReporter; + public ProblemReporter problemReporter; public ClassFilePool classFilePool; - // indicate in which step on the compilation we are. // step 1 : build the reference binding // step 2 : conect the hierarchy (connect bindings) // step 3 : build fields and method bindings. private int stepCompleted; public ITypeRequestor typeRequestor; + private ArrayBinding[][] uniqueArrayBindings; private SimpleLookupTable uniqueParameterizedTypeBindings; private SimpleLookupTable uniqueRawTypeBindings; @@ -67,9 +59,16 @@ public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems - private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4]; private MethodVerifier verifier; + final static int BUILD_FIELDS_AND_METHODS = 4; + final static int BUILD_TYPE_HIERARCHY = 1; + + final static int CHECK_AND_SET_IMPORTS = 2; + final static int CONNECT_TYPE_HIERARCHY = 3; + + static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound); + static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR_CHAR, null, NotFound); public LookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions globalOptions, ProblemReporter problemReporter, INameEnvironment nameEnvironment) { this.typeRequestor = typeRequestor; @@ -96,19 +95,18 @@ public ReferenceBinding askForType(char[][] compoundName) { NameEnvironmentAnswer answer = nameEnvironment.findType(compoundName); - if (answer == null) - return null; + if (answer == null) return null; - if (answer.isBinaryType()) + if (answer.isBinaryType()) { // the type was found as a .class file typeRequestor.accept(answer.getBinaryType(), computePackageFrom(compoundName), answer.getAccessRestriction()); - else if (answer.isCompilationUnit()) + } else if (answer.isCompilationUnit()) { // the type was found as a .java file, try to build it then search the cache typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); - else if (answer.isSourceType()) + } else if (answer.isSourceType()) { // the type was found as a source model typeRequestor.accept(answer.getSourceTypes(), computePackageFrom(compoundName), answer.getAccessRestriction()); - + } return getCachedType(compoundName); } /* Ask the oracle for a type named name in the packageBinding. @@ -125,47 +123,46 @@ if (answer == null) return null; - if (answer.isBinaryType()) + if (answer.isBinaryType()) { // the type was found as a .class file typeRequestor.accept(answer.getBinaryType(), packageBinding, answer.getAccessRestriction()); - else if (answer.isCompilationUnit()) + } else if (answer.isCompilationUnit()) { // the type was found as a .java file, try to build it then search the cache typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); - else if (answer.isSourceType()) + } else if (answer.isSourceType()) { // the type was found as a source model typeRequestor.accept(answer.getSourceTypes(), packageBinding, answer.getAccessRestriction()); - + } return packageBinding.getType0(name); } + /* Create the initial type bindings for the compilation unit. * * See completeTypeBindings() for a description of the remaining steps * * NOTE: This method can be called multiple times as additional source files are needed */ - public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction accessRestriction) { CompilationUnitScope scope = new CompilationUnitScope(unit, this); scope.buildTypeBindings(accessRestriction); - int unitsLength = units.length; if (++lastUnitIndex >= unitsLength) System.arraycopy(units, 0, units = new CompilationUnitDeclaration[2 * unitsLength], 0, unitsLength); units[lastUnitIndex] = unit; } + /* Cache the binary type since we know it is needed during this compile. * * Answer the created BinaryTypeBinding or null if the type is already in the cache. */ - public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, AccessRestriction accessRestriction) { return cacheBinaryType(binaryType, true, accessRestriction); } + /* Cache the binary type since we know it is needed during this compile. * * Answer the created BinaryTypeBinding or null if the type is already in the cache. */ - public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, boolean needFieldsAndMethods, AccessRestriction accessRestriction) { char[][] compoundName = CharOperation.splitOn('/', binaryType.getName()); ReferenceBinding existingType = getCachedType(compoundName); @@ -175,38 +172,6 @@ return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction); return null; // the type already exists & can be retrieved from the cache } -public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName, CompilationUnitDeclaration unit) { - // report the missing class file first - problemReporter.isClassPathCorrect( - compoundName, - unit == null ? this.unitBeingCompleted : unit, - this.missingClassFileLocation); - - PackageBinding packageBinding = computePackageFrom(compoundName); - // create a proxy for the missing BinaryType - MissingBinaryTypeBinding type = new MissingBinaryTypeBinding(packageBinding, compoundName, this); - if (type.id != TypeIds.T_JavaLangObject) { - // make Object be its superclass - it could in turn be missing as well - ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT); - if (objectType == null) - objectType = cacheMissingBinaryType(TypeConstants.JAVA_LANG_OBJECT, unit); // create a proxy for the missing Object type - type.setMissingSuperclass(objectType); - } - packageBinding.addType(type); - return type; -} -/* -* 1. Connect the type hierarchy for the type bindings created for parsedUnits. -* 2. Create the field bindings -* 3. Create the method bindings -*/ - -/* We know each known compilationUnit is free of errors at this point... -* -* Each step will create additional bindings unless a problem is detected, in which -* case either the faulty import/superinterface/field/method will be skipped or a -* suitable replacement will be substituted (such as Object for a missing superclass) -*/ public void completeTypeBindings() { stepCompleted = BUILD_TYPE_HIERARCHY; @@ -231,18 +196,19 @@ this.lastCompletedUnitIndex = this.lastUnitIndex; this.unitBeingCompleted = null; } + /* * 1. Connect the type hierarchy for the type bindings created for parsedUnits. * 2. Create the field bindings * 3. Create the method bindings */ -/* +/* We know each known compilationUnit is free of errors at this point... +* * Each step will create additional bindings unless a problem is detected, in which * case either the faulty import/superinterface/field/method will be skipped or a * suitable replacement will be substituted (such as Object for a missing superclass) */ - public void completeTypeBindings(CompilationUnitDeclaration parsedUnit) { if (stepCompleted == BUILD_FIELDS_AND_METHODS) { // This can only happen because the original set of units are completely built and @@ -261,6 +227,7 @@ this.unitBeingCompleted = null; } } + /* * Used by other compiler tools which do not start by calling completeTypeBindings(). * @@ -269,6 +236,11 @@ * 3. Create the method bindings */ +/* +* Each step will create additional bindings unless a problem is detected, in which +* case either the faulty import/superinterface/field/method will be skipped or a +* suitable replacement will be substituted (such as Object for a missing superclass) +*/ public void completeTypeBindings(CompilationUnitDeclaration parsedUnit, boolean buildFieldsAndMethods) { if (parsedUnit.scope == null) return; // parsing errors were too severe @@ -279,6 +251,7 @@ parsedUnit.scope.buildFieldsAndMethods(); this.unitBeingCompleted = null; } + public TypeBinding computeBoxingType(TypeBinding type) { TypeBinding boxedType; switch (type.id) { @@ -373,7 +346,8 @@ } } return type; -} +} + private PackageBinding computePackageFrom(char[][] constantPoolName) { if (constantPoolName.length == 1) return defaultPackage; @@ -392,30 +366,7 @@ } } return packageBinding; -} - -/** - * Convert a given source type into a parameterized form if generic. - * generic X --> param X - */ -public ReferenceBinding convertToParameterizedType(ReferenceBinding originalType) { - if (originalType != null) { - boolean isGeneric = originalType.isGenericType(); - ReferenceBinding originalEnclosingType = originalType.enclosingType(); - ReferenceBinding convertedEnclosingType = originalEnclosingType; - boolean needToConvert = isGeneric; - if (originalEnclosingType != null) { - convertedEnclosingType = originalType.isStatic() - ? (ReferenceBinding) convertToRawType(originalEnclosingType) - : convertToParameterizedType(originalEnclosingType); - needToConvert |= originalEnclosingType != convertedEnclosingType; - } - if (needToConvert) { - return createParameterizedType(originalType, isGeneric ? originalType.typeVariables() : null, convertedEnclosingType); - } - } - return originalType; -} +} public TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { @@ -534,6 +485,29 @@ return originalType; } +/** + * Convert a given source type into a parameterized form if generic. + * generic X --> param X + */ +public ReferenceBinding convertToParameterizedType(ReferenceBinding originalType) { + if (originalType != null) { + boolean isGeneric = originalType.isGenericType(); + ReferenceBinding originalEnclosingType = originalType.enclosingType(); + ReferenceBinding convertedEnclosingType = originalEnclosingType; + boolean needToConvert = isGeneric; + if (originalEnclosingType != null) { + convertedEnclosingType = originalType.isStatic() + ? (ReferenceBinding) convertToRawType(originalEnclosingType) + : convertToParameterizedType(originalEnclosingType); + needToConvert |= originalEnclosingType != convertedEnclosingType; + } + if (needToConvert) { + return createParameterizedType(originalType, isGeneric ? originalType.typeVariables() : null, convertedEnclosingType); + } + } + return originalType; +} + public TypeBinding convertToRawType(TypeBinding type) { int dimension; TypeBinding originalType; @@ -655,6 +629,7 @@ } return type; } + /* * Used to guarantee annotation identity. */ @@ -664,7 +639,6 @@ } return new AnnotationBinding(annotationType, pairs); } - /* * Used to guarantee array type identity. */ @@ -706,6 +680,7 @@ uniqueArrayBindings[dimIndex] = arrayBindings; return arrayBindings[length] = new ArrayBinding(leafComponentType, dimensionCount, this); } + public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { return createBinaryTypeFrom(binaryType, packageBinding, true, accessRestriction); } @@ -731,9 +706,35 @@ binaryBinding.cachePartsFrom(binaryType, needFieldsAndMethods); return binaryBinding; } -/* Used to create packages from the package statement. + +/* + * Used to create types denoting missing types */ +public MissingTypeBinding createMissingType(PackageBinding packageBinding, char[][] compoundName) { + // create a proxy for the missing BinaryType + if (packageBinding == null) { + packageBinding = computePackageFrom(TypeConstants.JAVA_LANG_OBJECT); + if (packageBinding == TheNotFoundPackage) packageBinding = this.defaultPackage; + } + MissingTypeBinding missingType = new MissingTypeBinding(packageBinding, compoundName, this); +// this.uniqueMissingTypeBindings.put(compoundName, missingType); + if (missingType.id != TypeIds.T_JavaLangObject) { + // make Object be its superclass - it could in turn be missing as well + ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT); + if (objectType == null) { + objectType = createMissingType(null, TypeConstants.JAVA_LANG_OBJECT); // create a proxy for the missing Object type + } + missingType.setMissingSuperclass(objectType); + } + packageBinding.addType(missingType); + return missingType; +} +/* +* 1. Connect the type hierarchy for the type bindings created for parsedUnits. +* 2. Create the field bindings +* 3. Create the method bindings +*/ public PackageBinding createPackage(char[][] compoundName) { PackageBinding packageBinding = getPackage0(compoundName[0]); if (packageBinding == null || packageBinding == TheNotFoundPackage) { @@ -769,7 +770,6 @@ } public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, RawTypeBinding rawType) { - // cached info is array of already created parameterized types for this type ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); boolean needToGrow = false; @@ -802,7 +802,6 @@ } public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, TypeBinding[] typeArguments) { - // cached info is array of already created parameterized types for this type ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); int argLength = typeArguments == null ? 0: typeArguments.length; @@ -842,7 +841,6 @@ } public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { - // cached info is array of already created parameterized types for this type ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType); int argLength = typeArguments == null ? 0: typeArguments.length; @@ -917,7 +915,6 @@ } public WildcardBinding createWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind) { - // cached info is array of already created wildcard types for this type if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation genericType = ReferenceBinding.LUB_GENERIC; @@ -977,14 +974,12 @@ * NOTE: Do not use for nested types... the answer is NOT the same for a.b.C or a.b.C.D.E * assuming C is a type in both cases. In the a.b.C.D.E case, null is the answer. */ - public ReferenceBinding getCachedType(char[][] compoundName) { if (compoundName.length == 1) { if (defaultPackage == null) return null; return defaultPackage.getType0(compoundName[0]); } - PackageBinding packageBinding = getPackage0(compoundName[0]); if (packageBinding == null || packageBinding == TheNotFoundPackage) return null; @@ -994,6 +989,7 @@ return null; return packageBinding.getType0(compoundName[compoundName.length - 1]); } + /* Answer the top level package named name if it exists in the cache. * Answer theNotFoundPackage if it could not be resolved the first time * it was looked up, otherwise answer null. @@ -1001,10 +997,10 @@ * NOTE: Senders must convert theNotFoundPackage into a real problem * package if its to returned. */ - PackageBinding getPackage0(char[] name) { return knownPackages.get(name); } + /* Answer the type corresponding to the compoundName. * Ask the name environment for the type if its not in the cache. * Fail with a classpath error if the type cannot be found. @@ -1014,15 +1010,18 @@ if (type != null) return type; // create a proxy for the missing BinaryType - return cacheMissingBinaryType( + // report the missing class file first + problemReporter.isClassPathCorrect( compoundName, - scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit()); + scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit(), + this.missingClassFileLocation); + return createMissingType(null, compoundName); } + /* Answer the top level package named name. * Ask the oracle for the package if its not in the cache. * Answer null if the package cannot be found. */ - PackageBinding getTopLevelPackage(char[] name) { PackageBinding packageBinding = getPackage0(name); if (packageBinding != null) { @@ -1039,11 +1038,11 @@ knownPackages.put(name, TheNotFoundPackage); // saves asking the oracle next time return null; } + /* Answer the type corresponding to the compoundName. * Ask the name environment for the type if its not in the cache. * Answer null if the type cannot be found. */ - public ReferenceBinding getType(char[][] compoundName) { ReferenceBinding referenceBinding; @@ -1086,6 +1085,7 @@ return new ProblemReferenceBinding(compoundName, referenceBinding, InternalNameProvided); return referenceBinding; } + private TypeBinding[] getTypeArgumentsFromSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType, ReferenceBinding genericType) { java.util.ArrayList args = new java.util.ArrayList(2); int rank = 0; @@ -1097,13 +1097,13 @@ args.toArray(typeArguments); return typeArguments; } + /* Answer the type corresponding to the compound name. * Does not ask the oracle for the type if its not found in the cache... instead an * unresolved type is returned which must be resolved before used. * * NOTE: Does NOT answer base types nor array types! */ - ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) { ReferenceBinding binding = getCachedType(compoundName); if (binding == null) { @@ -1111,21 +1111,26 @@ binding = new UnresolvedReferenceBinding(compoundName, packageBinding); packageBinding.addType(binding); } else if (binding == TheNotFoundType) { + // report the missing class file first + problemReporter.isClassPathCorrect( + compoundName, + this.unitBeingCompleted, + this.missingClassFileLocation); // create a proxy for the missing BinaryType - binding = cacheMissingBinaryType(compoundName, this.unitBeingCompleted); + binding = createMissingType(null, compoundName); } else if (!isParameterized) { // check raw type, only for resolved types binding = (ReferenceBinding) convertUnresolvedBinaryToRawType(binding); } return binding; } + /* Answer the type corresponding to the name from the binary file. * Does not ask the oracle for the type if its not found in the cache... instead an * unresolved type is returned which must be resolved before used. * * NOTE: Does NOT answer base types nor array types! */ - ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) { if (end == -1) end = signature.length; @@ -1133,13 +1138,13 @@ char[][] compoundName = CharOperation.splitOn('/', signature, start, end); return getTypeFromCompoundName(compoundName, isParameterized); } + /* Answer the type corresponding to the signature from the binary file. * Does not ask the oracle for the type if its not found in the cache... instead an * unresolved type is returned which must be resolved before used. * * NOTE: Does answer base types & array types. */ - TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) { int dimension = 0; while (signature[start] == '[') { @@ -1192,6 +1197,7 @@ return binding; return createArrayType(binding, dimension); } + TypeBinding getTypeFromTypeSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType) { // TypeVariableSignature = 'T' Identifier ';' // ArrayTypeSignature = '[' TypeSignature @@ -1203,7 +1209,6 @@ wrapper.start++; dimension++; } - if (wrapper.signature[wrapper.start] == 'T') { int varStart = wrapper.start + 1; int varEnd = wrapper.computeEnd(); @@ -1258,12 +1263,13 @@ wrapper.start++; // skip ';' return dimension == 0 ? (TypeBinding) parameterizedType : createArrayType(parameterizedType, dimension); } + TypeBinding getTypeFromVariantTypeSignature( - SignatureWrapper wrapper, - TypeVariableBinding[] staticVariables, - ReferenceBinding enclosingType, - ReferenceBinding genericType, - int rank) { + SignatureWrapper wrapper, + TypeVariableBinding[] staticVariables, + ReferenceBinding enclosingType, + ReferenceBinding genericType, + int rank) { // VariantTypeSignature = '-' TypeSignature // or '+' TypeSignature // or TypeSignature @@ -1295,8 +1301,8 @@ return nameEnvironment.isPackage(null, name); return nameEnvironment.isPackage(compoundName, name); } -// The method verifier is lazily initialized to guarantee the receiver, the compiler & the oracle are ready. +// The method verifier is lazily initialized to guarantee the receiver, the compiler & the oracle are ready. public MethodVerifier methodVerifier() { if (verifier == null) verifier = this.globalOptions.sourceLevel < ClassFileConstants.JDK1_5 @@ -1304,6 +1310,7 @@ : new MethodVerifier15(this); // covariance only if sourceLevel is >= 1.5 return verifier; } + public void reset() { this.defaultPackage = new PackageBinding(this); // assume the default package always exists this.defaultImports = null; @@ -1332,6 +1339,7 @@ // name environment has a longer life cycle, and must be reset in // the code which created it. } + /** * Associate a given type with some access restriction * (did not store the restriction directly into binding, since sparse information) @@ -1354,7 +1362,6 @@ } } } - if (this.uniqueWildcardBindings.get(unresolvedType) != null) { // update the key Object[] keys = this.uniqueWildcardBindings.keyTable; for (int i = 0, l = keys.length; i < l; i++) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v retrieving revision 1.92 diff -u -r1.92 TypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 12 Oct 2007 09:37:00 -0000 1.92 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 28 Nov 2007 18:11:41 -0000 @@ -104,6 +104,14 @@ } /** + * In case of problems, returns the closest match found. It may not be perfect match, but the + * result of a best effort to improve fault-tolerance. + */ +public TypeBinding closestMatch() { + return this; // by default no better type +} + +/** * Collect the substitutes into a map for certain type variables inside the receiver type * e.g. Collection.findSubstitute(T, Collection>): T --> List * Constraints: Index: search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java,v retrieving revision 1.60 diff -u -r1.60 TypeReferenceLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 28 Nov 2007 08:04:09 -0000 1.60 +++ search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 28 Nov 2007 18:11:45 -0000 @@ -223,7 +223,7 @@ } // Try to find best selection for match - ReferenceBinding typeBinding = null; + TypeBinding typeBinding = null; boolean lastButOne = false; if (binding instanceof ReferenceBinding) { typeBinding = (ReferenceBinding) binding; @@ -601,7 +601,7 @@ typeBinding = ((ArrayBinding) typeBinding).leafComponentType; if (typeBinding == null || typeBinding instanceof BaseTypeBinding) return; if (typeBinding instanceof ProblemReferenceBinding) { - ReferenceBinding original = ((ProblemReferenceBinding) typeBinding).closestMatch(); + TypeBinding original = typeBinding.closestMatch(); if (original == null) return; // original may not be set (bug 71279) typeBinding = original; } Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java,v retrieving revision 1.25 diff -u -r1.25 SelectionOnSingleNameReference.java --- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java 10 May 2006 18:03:41 -0000 1.25 +++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java 28 Nov 2007 18:11:34 -0000 @@ -33,6 +33,7 @@ import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; +import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; @@ -61,7 +62,7 @@ throw new SelectionNodeFound(binding); } scope.problemReporter().invalidField(this, (FieldBinding) binding); - } else if (binding instanceof ProblemReferenceBinding) { + } else if (binding instanceof ProblemReferenceBinding || binding instanceof MissingTypeBinding) { // tolerate some error cases if (binding.problemId() == ProblemReasons.NotVisible){ throw new SelectionNodeFound(binding); Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java,v retrieving revision 1.24 diff -u -r1.24 SelectionOnQualifiedNameReference.java --- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java 10 May 2006 18:03:41 -0000 1.24 +++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java 28 Nov 2007 18:11:34 -0000 @@ -35,6 +35,7 @@ import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; +import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; @@ -71,7 +72,7 @@ throw new SelectionNodeFound(binding); } scope.problemReporter().invalidField(this, (FieldBinding) binding); - } else if (binding instanceof ProblemReferenceBinding) { + } else if (binding instanceof ProblemReferenceBinding || binding instanceof MissingTypeBinding) { // tolerate some error cases if (binding.problemId() == ProblemReasons.NotVisible){ throw new SelectionNodeFound(binding); Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java,v retrieving revision 1.23 diff -u -r1.23 CompletionOnQualifiedNameReference.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java 12 Oct 2006 09:21:42 -0000 1.23 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java 28 Nov 2007 18:11:34 -0000 @@ -60,7 +60,7 @@ if (!binding.isValidBinding()) { if (binding instanceof ProblemFieldBinding) { scope.problemReporter().invalidField(this, (FieldBinding) binding); - } else if (binding instanceof ProblemReferenceBinding) { + } else if (binding instanceof ProblemReferenceBinding || binding instanceof MissingTypeBinding) { scope.problemReporter().invalidType(this, (TypeBinding) binding); } else { scope.problemReporter().unresolvableReference(this, binding); Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.76 diff -u -r1.76 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 21 Nov 2007 16:48:44 -0000 1.76 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 28 Nov 2007 18:11:44 -0000 @@ -330,10 +330,18 @@ int index = 0; for (int i = 0; i < length; i++) { ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType; - if (superInterface instanceof ProblemReferenceBinding) - superInterface = superInterface.closestMatch(); - if (superInterface != null) - interfaceBindings[index++] = superInterface; + if (superInterface != null) { + if (!superInterface.isValidBinding()) { + TypeBinding closestMatch = superInterface.closestMatch(); + if (closestMatch instanceof ReferenceBinding) { + superInterface = (ReferenceBinding) closestMatch; + } else { + superInterface = null; + } + } + if (superInterface != null) + interfaceBindings[index++] = superInterface; + } } if (index < length) System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[index], 0 , index); Index: compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java,v retrieving revision 1.81 diff -u -r1.81 ClassFileReader.java --- compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java 11 Jul 2007 13:40:56 -0000 1.81 +++ compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java 28 Nov 2007 18:11:37 -0000 @@ -298,7 +298,7 @@ } } } else if (CharOperation.equals(attributeName, AttributeNamesConstants.InconsistentHierarchy)) { - this.tagBits |= TagBits.HasInconsistentHierarchy; + this.tagBits |= TagBits.HierarchyHasProblems; } break; case 'S' : @@ -702,7 +702,7 @@ long OnlyStructuralTagBits = TagBits.AnnotationTargetMASK // different @Target status ? | TagBits.AnnotationDeprecated // different @Deprecated status ? | TagBits.AnnotationRetentionMASK // different @Retention status ? - | TagBits.HasInconsistentHierarchy; // different hierarchy status ? + | TagBits.HierarchyHasProblems; // different hierarchy status ? // meta-annotations if ((this.getTagBits() & OnlyStructuralTagBits) != (newClassFile.getTagBits() & OnlyStructuralTagBits)) Index: codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java,v retrieving revision 1.141 diff -u -r1.141 SelectionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 13 Nov 2007 13:12:33 -0000 1.141 +++ codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java 28 Nov 2007 18:11:34 -0000 @@ -841,7 +841,12 @@ } else if (binding instanceof ReferenceBinding) { ReferenceBinding typeBinding = (ReferenceBinding) binding; if(typeBinding instanceof ProblemReferenceBinding) { - typeBinding = typeBinding.closestMatch(); + TypeBinding closestMatch = typeBinding.closestMatch(); + if (closestMatch instanceof ReferenceBinding) { + typeBinding = (ReferenceBinding) closestMatch; + } else { + typeBinding = null; + } } if (typeBinding == null) return; if (isLocal(typeBinding) && this.requestor instanceof SelectionRequestor) { Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.348 diff -u -r1.348 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 5 Nov 2007 16:04:29 -0000 1.348 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 28 Nov 2007 18:11:34 -0000 @@ -4999,7 +4999,7 @@ } }; SingleTypeReference typeRef = new SingleTypeReference(token, pos); - typeRef.resolvedType = new ProblemReferenceBinding(token, null, ProblemReasons.NotFound); + typeRef.resolvedType = new ProblemReferenceBinding(new char[][]{ token }, null, ProblemReasons.NotFound); missingTypesConverter.guess(typeRef, scope, substitutionRequestor); } @@ -9402,7 +9402,7 @@ } typeBindings[nodeIndex] = scope.getJavaLangObject(); if(typeVariables == null || typeVariables.length == 0) { - scope.problemReporter().nonGenericTypeCannotBeParameterized(ref, ref.resolvedType, typeBindings); + scope.problemReporter().nonGenericTypeCannotBeParameterized(0, ref, ref.resolvedType, typeBindings); } else { scope.problemReporter().incorrectArityForParameterizedType(ref, ref.resolvedType, typeBindings); } @@ -9423,7 +9423,7 @@ } typeBindings[j] = scope.getJavaLangObject(); if(typeVariables == null || typeVariables.length == 0) { - scope.problemReporter().nonGenericTypeCannotBeParameterized(ref, ref.resolvedType, typeBindings); + scope.problemReporter().nonGenericTypeCannotBeParameterized(0, ref, ref.resolvedType, typeBindings); } else { scope.problemReporter().incorrectArityForParameterizedType(ref, ref.resolvedType, typeBindings); } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java,v retrieving revision 1.49 diff -u -r1.49 CodeSnippetScope.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 23 Jul 2007 18:41:48 -0000 1.49 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java 28 Nov 2007 18:11:44 -0000 @@ -447,7 +447,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!this.canBeSeenByForCodeSnippet((ReferenceBinding) binding, receiverType)) return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), (ReferenceBinding) binding, ProblemReasons.NotVisible); @@ -480,7 +480,7 @@ if (!binding.isValidBinding()) return new ProblemReferenceBinding( CharOperation.subarray(compoundName, 0, currentIndex), - ((ReferenceBinding)binding).closestMatch(), + (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); } Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v retrieving revision 1.157 diff -u -r1.157 DefaultBindingResolver.java --- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 16 Jul 2007 21:03:36 -0000 1.157 +++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 28 Nov 2007 18:11:44 -0000 @@ -322,7 +322,7 @@ case ProblemReasons.NonStaticReferenceInStaticContext : if (referenceBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding; - ReferenceBinding binding2 = problemReferenceBinding.closestMatch(); + org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding2 = problemReferenceBinding.closestMatch(); ITypeBinding binding = (ITypeBinding) this.bindingTables.compilerBindingsToASTBindings.get(binding2); if (binding != null) { return binding; 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.363 diff -u -r1.363 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 21 Nov 2007 14:15:24 -0000 1.363 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Nov 2007 18:11:43 -0000 @@ -3720,18 +3720,19 @@ return false; } } + private boolean isRecoveredName(char[] simpleName) { return simpleName == RecoveryScanner.FAKE_IDENTIFIER; } + private boolean isRecoveredName(char[][] qualifiedName) { if(qualifiedName == null) return false; - for (int i = 0; i < qualifiedName.length; i++) { if(qualifiedName[i] == RecoveryScanner.FAKE_IDENTIFIER) return true; } - return false; } + public void javadocAmbiguousMethodReference(int sourceStart, int sourceEnd, Binding fieldBinding, int modifiers) { int severity = computeSeverity(IProblem.JavadocAmbiguousMethodReference); if (severity == ProblemSeverities.Ignore) return; @@ -4499,15 +4500,19 @@ sourceEnd); } } + public void javadocUnexpectedTag(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocUnexpectedTag, NoArgument, NoArgument, sourceStart, sourceEnd); } + public void javadocUnexpectedText(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocUnexpectedText, NoArgument, NoArgument, sourceStart, sourceEnd); } + public void javadocUnterminatedInlineTag(int sourceStart, int sourceEnd) { this.handle(IProblem.JavadocUnterminatedInlineTag, NoArgument, NoArgument, sourceStart, sourceEnd); } + private boolean javadocVisibility(int visibility, int modifiers) { if (modifiers < 0) return true; switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) { @@ -4522,6 +4527,7 @@ } return true; } + private String javadocVisibilityArgument(int visibility, int modifiers) { String argument = null; switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) { @@ -4546,6 +4552,7 @@ } return argument; } + public void localVariableHiding(LocalDeclaration local, Binding hiddenVariable, boolean isSpecialArgHidingField) { if (hiddenVariable instanceof LocalVariableBinding) { int id = (local instanceof Argument) @@ -4580,6 +4587,7 @@ local.sourceEnd); } } + public void localVariableNonNullComparedToNull(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.NonNullLocalVariableComparisonYieldsFalse); if (severity == ProblemSeverities.Ignore) return; @@ -4592,6 +4600,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableNullComparedToNonNull(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.NullLocalVariableComparisonYieldsFalse); if (severity == ProblemSeverities.Ignore) return; @@ -4604,6 +4613,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableNullInstanceof(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.NullLocalVariableInstanceofYieldsFalse); if (severity == ProblemSeverities.Ignore) return; @@ -4616,6 +4626,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableNullReference(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.NullLocalVariableReference); if (severity == ProblemSeverities.Ignore) return; @@ -4628,6 +4639,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariablePotentialNullReference(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.PotentialNullLocalVariableReference); if (severity == ProblemSeverities.Ignore) return; @@ -4640,6 +4652,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableRedundantCheckOnNonNull(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.RedundantNullCheckOnNonNullLocalVariable); if (severity == ProblemSeverities.Ignore) return; @@ -4652,6 +4665,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableRedundantCheckOnNull(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.RedundantNullCheckOnNullLocalVariable); if (severity == ProblemSeverities.Ignore) return; @@ -4664,6 +4678,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location) { int severity = computeSeverity(IProblem.RedundantLocalVariableNullAssignment); if (severity == ProblemSeverities.Ignore) return; @@ -4676,6 +4691,7 @@ nodeSourceStart(local, location), nodeSourceEnd(local, location)); } + public void methodMustOverride(AbstractMethodDeclaration method) { MethodBinding binding = method.binding; this.handle( @@ -4685,6 +4701,7 @@ method.sourceStart, method.sourceEnd); } + public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) { this.handle( IProblem.MethodNameClash, @@ -4705,6 +4722,7 @@ currentMethod.sourceStart(), currentMethod.sourceEnd()); } + public void methodNeedBody(AbstractMethodDeclaration methodDecl) { this.handle( IProblem.MethodRequiresBody, @@ -4713,6 +4731,7 @@ methodDecl.sourceStart, methodDecl.sourceEnd); } + public void methodNeedingNoBody(MethodDeclaration methodDecl) { this.handle( ((methodDecl.modifiers & ClassFileConstants.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod, @@ -4730,6 +4749,7 @@ methodDecl.sourceStart, methodDecl.sourceEnd); } + public void missingDeprecatedAnnotationForField(FieldDeclaration field) { int severity = computeSeverity(IProblem.FieldMissingDeprecatedAnnotation); if (severity == ProblemSeverities.Ignore) return; @@ -5055,9 +5075,7 @@ location.sourceStart, location.sourceEnd); } -public void nonGenericTypeCannotBeParameterized(ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) { - this.nonGenericTypeCannotBeParameterized(0, location, type, argumentTypes); -} + public void nonGenericTypeCannotBeParameterized(int index, ASTNode location, TypeBinding type, TypeBinding[] argumentTypes) { if (location == null) { // binary case this.handle( Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java =================================================================== RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MissingTypeBinding.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.compiler.lookup; + +import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; + +public class MissingTypeBinding extends BinaryTypeBinding { + +/** + * Special constructor for constructing proxies of missing types (114349) + * @param packageBinding + * @param compoundName + * @param environment + */ +public MissingTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) { + this.compoundName = compoundName; + computeId(); + this.tagBits |= TagBits.IsBinaryBinding | TagBits.HierarchyHasProblems | TagBits.HasMissingType; + this.environment = environment; + this.fPackage = packageBinding; + this.fileName = CharOperation.concatWith(compoundName, '/'); + this.sourceName = compoundName[compoundName.length - 1]; // [java][util][Map$Entry] + this.modifiers = ClassFileConstants.AccPublic; + this.superclass = null; // will be fixed up using #setMissingSuperclass(...) + this.superInterfaces = Binding.NO_SUPERINTERFACES; + this.typeVariables = Binding.NO_TYPE_VARIABLES; + this.memberTypes = Binding.NO_MEMBER_TYPES; + this.fields = Binding.NO_FIELDS; + this.methods = Binding.NO_METHODS; +} + +/** + * Missing binary type will answer false to #isValidBinding() + * @see org.eclipse.jdt.internal.compiler.lookup.Binding#problemId() + */ +public int problemId() { + return ProblemReasons.NotFound; +} + +/** + * Only used to fixup the superclass hierarchy of proxy binary types + * @param missingSuperclass + * @see LookupEnvironment#createMissingType(PackageBinding, char[][]) + */ +void setMissingSuperclass(ReferenceBinding missingSuperclass) { + this.superclass = missingSuperclass; +} + +public String toString() { + return "[MISSING:" + new String(CharOperation.concatWith(this.compoundName, '.')) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } +} #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java,v retrieving revision 1.33 diff -u -r1.33 ComplianceDiagnoseTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java 16 Oct 2007 10:24:52 -0000 1.33 +++ src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java 28 Nov 2007 18:11:49 -0000 @@ -484,6 +484,11 @@ " this(null);\n" + " ^^\n" + "Y2 cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " this(null);\n" + + " ^^^^^^^^^^^\n" + + "The constructor X(null) is undefined\n" + "----------\n"; runComplianceParserTest( @@ -2029,11 +2034,6 @@ " super(\"SUCCESS\");\n" + " ^^^^^^\n" + "Syntax error, parameterized types are only available if source level is 5.0\n" + - "----------\n" + - "6. ERROR in X.java (at line 9)\n" + - " super(\"SUCCESS\");\n" + - " ^^^^^^^^^^^^^^^^^\n" + - "The constructor X(String) is undefined\n" + "----------\n"; String expected14ProblemLog = expected13ProblemLog; Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v retrieving revision 1.173 diff -u -r1.173 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 21 Nov 2007 17:54:29 -0000 1.173 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 28 Nov 2007 18:11:51 -0000 @@ -6016,18 +6016,27 @@ "\n", // ================= }, "----------\n" + - "1. ERROR in X.java (at line 3)\n" + - " y.initialize(null, null, null);\n" + - " ^^^^^^^^^^\n" + - "The method initialize(null, null, null) is undefined for the type Y\n" + - "----------\n" + + "1. WARNING in Y.java (at line 6)\n" + + " public void initialize(Zork z, String s) {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The deprecated method initialize(Zork, String) of type Y should be annotated with @Deprecated\n" + "----------\n" + - "1. ERROR in Y.java (at line 6)\n" + + "2. ERROR in Y.java (at line 6)\n" + " public void initialize(Zork z, String s) {\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + "----------\n" + - "2. ERROR in Y.java (at line 9)\n" + + "3. ERROR in Y.java (at line 6)\n" + + " public void initialize(Zork z, String s) {\n" + + " ^\n" + + "Javadoc: Missing tag for parameter z\n" + + "----------\n" + + "4. ERROR in Y.java (at line 6)\n" + + " public void initialize(Zork z, String s) {\n" + + " ^\n" + + "Javadoc: Missing tag for parameter s\n" + + "----------\n" + + "5. ERROR in Y.java (at line 9)\n" + " public void initialize(Zork z, String s, Thread t) {\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + @@ -6058,13 +6067,23 @@ "1. ERROR in X.java (at line 3)\n" + " int i = y.initialize;\n" + " ^^^^^^^^^^^^\n" + - "y.initialize cannot be resolved or is not a field\n" + + "Type mismatch: cannot convert from Zork to int\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " int i = y.initialize;\n" + + " ^^^^^^^^^^\n" + + "The field Y.initialize is deprecated\n" + "----------\n" + "----------\n" + "1. ERROR in Y.java (at line 6)\n" + " public Zork initialize;\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. WARNING in Y.java (at line 6)\n" + + " public Zork initialize;\n" + + " ^^^^^^^^^^\n" + + "The deprecated field Y.initialize should be annotated with @Deprecated\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=110593 - variation @@ -6791,8 +6810,8 @@ "----------\n" + "1. ERROR in X.java (at line 2)\n" + " @Ann(m=bar(null))\n" + - " ^^^\n" + - "The method bar(null) is undefined for the type X\n" + + " ^^^^^^^^^\n" + + "Type mismatch: cannot convert from NonExisting to String\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " private NonExisting bar(NonExisting ne){}\n" + @@ -6853,8 +6872,8 @@ "----------\n" + "1. ERROR in X.java (at line 2)\n" + " @Ann(m=bar())\n" + - " ^^^\n" + - "The method bar() is undefined for the type X\n" + + " ^^^^^\n" + + "Type mismatch: cannot convert from NonExisting to String\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " private NonExisting bar(){}\n" + @@ -6880,14 +6899,19 @@ "1. ERROR in X.java (at line 2)\n" + " @Ann(m=foo)\n" + " ^^^\n" + - "foo cannot be resolved\n" + + "Cannot reference a field before it is defined\n" + "----------\n" + - "2. ERROR in X.java (at line 3)\n" + + "2. ERROR in X.java (at line 2)\n" + + " @Ann(m=foo)\n" + + " ^^^\n" + + "Type mismatch: cannot convert from NonExisting to String\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + " private NonExisting foo;\n" + " ^^^^^^^^^^^\n" + "NonExisting cannot be resolved to a type\n" + "----------\n" + - "3. ERROR in X.java (at line 4)\n" + + "4. ERROR in X.java (at line 4)\n" + " private NonExisting bar;\n" + " ^^^^^^^^^^^\n" + "NonExisting cannot be resolved to a type\n" + @@ -7590,10 +7614,15 @@ "----------\n" + "3. ERROR in X.java (at line 6)\n" + " @Annot(value={x}, classe={Zork.class,zork})\n" + + " ^^^^^^^^^^\n" + + "Type mismatch: cannot convert from Class to Class\n" + + "----------\n" + + "4. ERROR in X.java (at line 6)\n" + + " @Annot(value={x}, classe={Zork.class,zork})\n" + " ^^^^\n" + "zork cannot be resolved\n" + "----------\n" + - "4. ERROR in X.java (at line 6)\n" + + "5. ERROR in X.java (at line 6)\n" + " @Annot(value={x}, classe={Zork.class,zork})\n" + " ^^^^\n" + "The value for annotation attribute X.Annot.classe must be a class literal\n" + @@ -7832,6 +7861,11 @@ " ArrayList al = null;\n" + " ^^^^^^^^^\n" + "ArrayList cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " List ls = al;\n" + + " ^^\n" + + "Type mismatch: cannot convert from ArrayList to List\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=207758 - variation @@ -7853,8 +7887,8 @@ "----------\n" + "1. ERROR in X.java (at line 5)\n" + " List ls = bar();\n" + - " ^^^\n" + - "The method bar() is undefined for the type X\n" + + " ^^^^^\n" + + "Type mismatch: cannot convert from ArrayList to List\n" + "----------\n" + "2. ERROR in X.java (at line 7)\n" + " ArrayList bar() {\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java,v retrieving revision 1.24 diff -u -r1.24 JavadocTestForMethod.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java 3 Oct 2006 15:19:13 -0000 1.24 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java 28 Nov 2007 18:11:55 -0000 @@ -946,22 +946,32 @@ + " public void p_foo(inr a, inx b, inq c) {\n" + " }\n" + "}\n" }, - "----------\n" - + "1. ERROR in X.java (at line 8)\n" - + " public void p_foo(inr a, inx b, inq c) {\n" - + " ^^^\n" - + "inr cannot be resolved to a type\n" - + "----------\n" - + "2. ERROR in X.java (at line 8)\n" - + " public void p_foo(inr a, inx b, inq c) {\n" - + " ^^^\n" - + "inx cannot be resolved to a type\n" - + "----------\n" - + "3. ERROR in X.java (at line 8)\n" - + " public void p_foo(inr a, inx b, inq c) {\n" - + " ^^^\n" - + "inq cannot be resolved to a type\n" - + "----------\n"); + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " * @param b Valid param\n" + + " ^\n" + + "Javadoc: Duplicate tag for parameter\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " public void p_foo(inr a, inx b, inq c) {\n" + + " ^^^\n" + + "inr cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " public void p_foo(inr a, inx b, inq c) {\n" + + " ^\n" + + "Javadoc: Missing tag for parameter a\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " public void p_foo(inr a, inx b, inq c) {\n" + + " ^^^\n" + + "inx cannot be resolved to a type\n" + + "----------\n" + + "5. ERROR in X.java (at line 8)\n" + + " public void p_foo(inr a, inx b, inq c) {\n" + + " ^^^\n" + + "inq cannot be resolved to a type\n" + + "----------\n"); } public void test037() { Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java,v retrieving revision 1.29 diff -u -r1.29 JavadocTest_1_3.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java 4 Oct 2007 13:02:14 -0000 1.29 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java 28 Nov 2007 18:11:55 -0000 @@ -1450,25 +1450,20 @@ "----------\n" + "3. ERROR in X.java (at line 5)\n" + " public class X extends G {\n" + - " ^\n" + - "The type G is not generic; it cannot be parameterized with arguments \n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " public class X extends G {\n" + " ^^^^^^^^^\n" + "Syntax error, parameterized types are only available if source level is 5.0\n" + "----------\n" + - "5. ERROR in X.java (at line 6)\n" + + "4. ERROR in X.java (at line 6)\n" + " X(Exception exc) { super(exc);}\n" + " ^^^^^^^^^^^\n" + - "The constructor Object(Exception) is undefined\n" + + "The constructor G(Exception) is undefined\n" + "----------\n" + - "6. ERROR in X.java (at line 8)\n" + + "5. ERROR in X.java (at line 8)\n" + " class G {\n" + " ^^^^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "7. ERROR in X.java (at line 9)\n" + + "6. ERROR in X.java (at line 9)\n" + " G(E e) {}\n" + " ^\n" + "E cannot be resolved to a type\n" + @@ -1523,15 +1518,10 @@ " ^^^^^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "5. ERROR in X.java (at line 13)\n" + - " /** Tests the method{@link ComparableUtils#compareTo(Object, Object, Class)} and\n" + - " ^^^^^^^^^\n" + - "Javadoc: The method compareTo(X, X) in the type ComparableUtils is not applicable for the arguments (Object, Object, Class)\n" + - "----------\n" + - "6. ERROR in X.java (at line 14)\n" + + "5. ERROR in X.java (at line 14)\n" + " * {@link ComparableUtils#compareTo(Object, Object)}.\n" + " ^^^^^^^^^\n" + - "Javadoc: The method compareTo(X, X) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + + "Javadoc: The method compareTo(Object, Object, Class) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + "----------\n"); } @@ -1626,17 +1616,16 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "12. ERROR in Test.java (at line 19)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "13. ERROR in Test.java (at line 20)\n" + + "12. ERROR in Test.java (at line 20)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n" + + "13. ERROR in Test.java (at line 23)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + + "----------\n"); } public void testBug83127b() { reportMissingJavadocTags = CompilerOptions.IGNORE; @@ -1715,15 +1704,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 19)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 20)\n" + + "10. ERROR in Test.java (at line 20)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 23)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1801,15 +1790,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1908,15 +1897,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1973,7 +1962,7 @@ "1. ERROR in Test.java (at line 2)\n" + " * @see Unrelated1#add(Object)\n" + " ^^^\n" + - "Javadoc: The method add(Object) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Object)\n" + "----------\n" + "2. ERROR in Test.java (at line 3)\n" + " * @see Unrelated1#Unrelated1(Object)\n" + @@ -2015,15 +2004,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2060,76 +2049,76 @@ "}\n" }, "----------\n" + - "1. ERROR in Unrelated1.java (at line 1)\r\n" + - " public class Unrelated1 {\r\n" + + "1. ERROR in Unrelated1.java (at line 1)\n" + + " public class Unrelated1 {\n" + " ^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "2. ERROR in Unrelated1.java (at line 2)\r\n" + - " public Unrelated1(E e) {}\r\n" + + "2. ERROR in Unrelated1.java (at line 2)\n" + + " public Unrelated1(E e) {}\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "3. ERROR in Unrelated1.java (at line 3)\r\n" + - " public boolean add(E e) { return false; }\r\n" + + "3. ERROR in Unrelated1.java (at line 3)\n" + + " public boolean add(E e) { return false; }\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + "----------\n" + - "1. ERROR in Test.java (at line 2)\r\n" + - " * @see Unrelated1#add(Number)\r\n" + + "1. ERROR in Test.java (at line 2)\n" + + " * @see Unrelated1#add(Number)\n" + " ^^^\n" + - "Javadoc: The method add(Number) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Number)\n" + "----------\n" + - "2. ERROR in Test.java (at line 3)\r\n" + - " * @see Unrelated1#Unrelated1(Number)\r\n" + + "2. ERROR in Test.java (at line 3)\n" + + " * @see Unrelated1#Unrelated1(Number)\n" + " ^^^^^^^^^^^^^^^^^^\n" + "Javadoc: The constructor Unrelated1(Number) is undefined\n" + "----------\n" + - "3. ERROR in Test.java (at line 8)\r\n" + - " public class Test{\r\n" + + "3. ERROR in Test.java (at line 8)\n" + + " public class Test{\n" + " ^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "4. ERROR in Test.java (at line 9)\r\n" + - " Test(T t) {}\r\n" + + "4. ERROR in Test.java (at line 9)\n" + + " Test(T t) {}\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "5. ERROR in Test.java (at line 10)\r\n" + - " public boolean add(T t) {\r\n" + + "5. ERROR in Test.java (at line 10)\n" + + " public boolean add(T t) {\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "6. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "6. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "7. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "7. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^\n" + "Syntax error, parameterized types are only available if source level is 5.0\n" + "----------\n" + - "8. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "8. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "9. ERROR in Test.java (at line 15)\r\n" + - " Sub (E e) {super(null);}\r\n" + + "9. ERROR in Test.java (at line 15)\n" + + " Sub (E e) {super(null);}\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 15)\r\n" + - " Sub (E e) {super(null);}\r\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 16)\r\n" + - " public boolean add(E e) {\r\n" + + "10. ERROR in Test.java (at line 16)\n" + + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 19)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2187,7 +2176,7 @@ "1. ERROR in Test.java (at line 2)\n" + " * @see Unrelated1#add(Integer)\n" + " ^^^\n" + - "Javadoc: The method add(Integer) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Integer)\n" + "----------\n" + "2. ERROR in Test.java (at line 3)\n" + " * @see Unrelated1#Unrelated1(Integer)\n" + @@ -2229,15 +2218,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 17)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 18)\n" + + "10. ERROR in Test.java (at line 18)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 21)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2275,7 +2264,7 @@ " }\n" + "}\n" }, - "----------\n" + + "----------\n" + "1. ERROR in Unrelated2.java (at line 1)\n" + " public interface Unrelated2 {\n" + " ^\n" + @@ -2327,15 +2316,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "9. ERROR in Test.java (at line 18)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "10. ERROR in Test.java (at line 19)\n" + + "9. ERROR in Test.java (at line 19)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "10. ERROR in Test.java (at line 22)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n"); } @@ -3707,32 +3696,21 @@ "}\n" }, "----------\n" + - "1. ERROR in Test.java (at line 3)\n" + - " * @see Test#field\n" + - " ^^^^^\n" + - "Javadoc: field cannot be resolved or is not a field\n" + - "----------\n" + - "2. ERROR in Test.java (at line 4)\n" + - " * @see Test#foo()\n" + - " ^^^\n" + - "Javadoc: The method foo() is undefined for the type Test\n" + - "----------\n" + - "3. ERROR in Test.java (at line 6)\n" + + "1. ERROR in Test.java (at line 6)\n" + " public class Test {\n" + " ^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "4. ERROR in Test.java (at line 7)\n" + + "2. ERROR in Test.java (at line 7)\n" + " T field;\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "5. ERROR in Test.java (at line 8)\n" + + "3. ERROR in Test.java (at line 8)\n" + " T foo() { return null; }\n" + " ^\n" + "T cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n"); } /** Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java,v retrieving revision 1.29 diff -u -r1.29 InnerEmulationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 21 Nov 2007 14:15:12 -0000 1.29 +++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 28 Nov 2007 18:11:53 -0000 @@ -1168,20 +1168,14 @@ "----------\n" + "2. ERROR in p2\\c2.java (at line 6)\n" + " myC1a = new c1m().new c1a(); \n" + - " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" + - "3. ERROR in p2\\c2.java (at line 6)\n" + - " myC1a = new c1m().new c1a(); \n" + " ^^^\n" + "The type c1.c1m.c1a is not visible\n" + "----------\n" + - "4. ERROR in p2\\c2.java (at line 7)\n" + + "3. ERROR in p2\\c2.java (at line 7)\n" + " myC1a.foo(); \n" + " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" - ); + "The type c1.c1m.c1a is not visible\n" + + "----------\n"); } /** * Compatability - Compiler does not comply with 1.1 standard. @@ -1229,25 +1223,19 @@ "----------\n" + "2. ERROR in p2\\c2.java (at line 6)\n" + " myC1a = new c1m().new c1a(); \n" + - " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" + - "3. ERROR in p2\\c2.java (at line 6)\n" + - " myC1a = new c1m().new c1a(); \n" + " ^^^^^^^^^\n" + "The constructor c1.c1m() is not visible\n" + "----------\n" + - "4. ERROR in p2\\c2.java (at line 6)\n" + + "3. ERROR in p2\\c2.java (at line 6)\n" + " myC1a = new c1m().new c1a(); \n" + " ^^^\n" + "The type c1.c1m.c1a is not visible\n" + "----------\n" + - "5. ERROR in p2\\c2.java (at line 7)\n" + + "4. ERROR in p2\\c2.java (at line 7)\n" + " myC1a.foo(); \n" + " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" - ); + "The type c1.c1m.c1a is not visible\n" + + "----------\n"); } /** * Compatability - Compiler does not comply with 1.1 standard. @@ -1336,20 +1324,9 @@ "----------\n" + "3. ERROR in p2\\c2.java (at line 6)\n" + " myC1a = new c1a(); \n" + - " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" + - "4. ERROR in p2\\c2.java (at line 6)\n" + - " myC1a = new c1a(); \n" + " ^^^\n" + "c1a cannot be resolved to a type\n" + - "----------\n" + - "5. ERROR in p2\\c2.java (at line 7)\n" + - " myC1a.foo(); \n" + - " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" - ); + "----------\n"); } /** * Compatability - Compiler does not comply with 1.1 standard. @@ -1400,21 +1377,14 @@ "----------\n" + "3. ERROR in p2\\c2.java (at line 6)\n" + " myC1a = new c1a(); \n" + - " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" + - "4. ERROR in p2\\c2.java (at line 6)\n" + - " myC1a = new c1a(); \n" + " ^^^\n" + "The type c1a is not visible\n" + "----------\n" + - "5. ERROR in p2\\c2.java (at line 7)\n" + + "4. ERROR in p2\\c2.java (at line 7)\n" + " myC1a.foo(); \n" + " ^^^^^\n" + - "myC1a cannot be resolved\n" + - "----------\n" - - ); + "The type c1.c1a is not visible\n" + + "----------\n"); } /** * VerifyError using .class literal inside inner classes @@ -5999,50 +5969,65 @@ " ^^^^^\n" + "Zork1 cannot be resolved to a type\n" + "----------\n" + - "7. ERROR in X.java (at line 19)\n" + + "7. WARNING in X.java (at line 14)\n" + + " Zork1 z;\n" + + " ^\n" + + "The local variable z is hiding a field from type X.Member\n" + + "----------\n" + + "8. ERROR in X.java (at line 19)\n" + " new X().new IM();\n" + " ^^\n" + "Cannot instantiate the type X.IM\n" + "----------\n" + - "8. ERROR in X.java (at line 20)\n" + + "9. ERROR in X.java (at line 20)\n" + " class Local extends X { \n" + " ^\n" + "The type Local cannot subclass the final class X\n" + "----------\n" + - "9. ERROR in X.java (at line 21)\n" + + "10. ERROR in X.java (at line 21)\n" + " ZorkLocal z;\n" + " ^^^^^^^^^\n" + "ZorkLocal cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in X.java (at line 23)\n" + + "11. ERROR in X.java (at line 23)\n" + " this.bar();\n" + " ^^^\n" + "The method bar() is undefined for the type Local\n" + "----------\n" + - "11. ERROR in X.java (at line 24)\n" + + "12. ERROR in X.java (at line 24)\n" + " Zork3 z;\n" + " ^^^^^\n" + "Zork3 cannot be resolved to a type\n" + "----------\n" + - "12. ERROR in X.java (at line 27)\n" + + "13. WARNING in X.java (at line 24)\n" + + " Zork3 z;\n" + + " ^\n" + + "The local variable z is hiding a field from type Local\n" + + "----------\n" + + "14. ERROR in X.java (at line 27)\n" + " new X() {\n" + " ^\n" + "An anonymous class cannot subclass the final class X\n" + "----------\n" + - "13. ERROR in X.java (at line 28)\n" + + "15. ERROR in X.java (at line 28)\n" + " ZorkAnonymous2 z; \n" + " ^^^^^^^^^^^^^^\n" + "ZorkAnonymous2 cannot be resolved to a type\n" + "----------\n" + - "14. ERROR in X.java (at line 30)\n" + + "16. ERROR in X.java (at line 30)\n" + " this.bar();\n" + " ^^^\n" + "The method bar() is undefined for the type new X(){}\n" + "----------\n" + - "15. ERROR in X.java (at line 31)\n" + + "17. ERROR in X.java (at line 31)\n" + " Zork4 z;\n" + " ^^^^^\n" + "Zork4 cannot be resolved to a type\n" + + "----------\n" + + "18. WARNING in X.java (at line 31)\n" + + " Zork4 z;\n" + + " ^\n" + + "The local variable z is hiding a field from type new X(){}\n" + "----------\n"); } public static Class testClass() { Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.140 diff -u -r1.140 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 8 Nov 2007 16:28:43 -0000 1.140 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 28 Nov 2007 18:12:00 -0000 @@ -7098,8 +7098,28 @@ "----------\n" + "2. ERROR in X.java (at line 6)\n" + " Object foo() {\n" + + " ^^^^^^\n" + + "The return type is incompatible with Y.foo()\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " Object foo() {\n" + + " ^^^^^\n" + + "The method X.foo() is overriding a method without making a super invocation\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " Object foo() {\n" + + " ^^^^^^\n" + + "The return type is incompatible with Y.foo()\n" + + "----------\n" + + "5. WARNING in X.java (at line 8)\n" + + " Object foo() {\n" + " ^^^^^\n" + - mustOverrideMessage("foo()", "X") + + "The method foo() of type new Y(){} should be tagged with @Override since it actually overrides a superclass method\n" + + "----------\n" + + "6. ERROR in X.java (at line 8)\n" + + " Object foo() {\n" + + " ^^^^^\n" + + "The method new Y(){}.foo() is overriding a method without making a super invocation\n" + "----------\n", null, true, Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java,v retrieving revision 1.32 diff -u -r1.32 JavadocTest_1_4.java --- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java 4 Oct 2007 13:02:14 -0000 1.32 +++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java 28 Nov 2007 18:11:56 -0000 @@ -1451,30 +1451,24 @@ "----------\n" + "3. ERROR in X.java (at line 5)\n" + " public class X extends G {\n" + - " ^\n" + - "The type G is not generic; it cannot be parameterized with arguments \n" + - "----------\n" + - "4. ERROR in X.java (at line 5)\n" + - " public class X extends G {\n" + " ^^^^^^^^^\n" + "Syntax error, parameterized types are only available if source level is 5.0\n" + "----------\n" + - "5. ERROR in X.java (at line 6)\n" + + "4. ERROR in X.java (at line 6)\n" + " X(Exception exc) { super(exc);}\n" + " ^^^^^^^^^^^\n" + - "The constructor Object(Exception) is undefined\n" + + "The constructor G(Exception) is undefined\n" + "----------\n" + - "6. ERROR in X.java (at line 8)\n" + + "5. ERROR in X.java (at line 8)\n" + " class G {\n" + " ^^^^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "7. ERROR in X.java (at line 9)\n" + + "6. ERROR in X.java (at line 9)\n" + " G(E e) {}\n" + " ^\n" + "E cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n"); } /** @@ -1524,17 +1518,11 @@ " ^^^^^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "5. ERROR in X.java (at line 13)\n" + - " /** Tests the method{@link ComparableUtils#compareTo(Object, Object, Class)} and\n" + - " ^^^^^^^^^\n" + - "Javadoc: The method compareTo(X, X) in the type ComparableUtils is not applicable for the arguments (Object, Object, Class)\n" + - "----------\n" + - "6. ERROR in X.java (at line 14)\n" + + "5. ERROR in X.java (at line 14)\n" + " * {@link ComparableUtils#compareTo(Object, Object)}.\n" + " ^^^^^^^^^\n" + - "Javadoc: The method compareTo(X, X) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + - "----------\n" - ); + "Javadoc: The method compareTo(Object, Object, Class) in the type ComparableUtils is not applicable for the arguments (Object, Object)\n" + + "----------\n"); } /** @@ -1628,17 +1616,16 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "12. ERROR in Test.java (at line 19)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "13. ERROR in Test.java (at line 20)\n" + + "12. ERROR in Test.java (at line 20)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n" + + "13. ERROR in Test.java (at line 23)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + + "----------\n"); } public void testBug83127b() { reportMissingJavadocTags = CompilerOptions.IGNORE; @@ -1717,15 +1704,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 19)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 20)\n" + + "10. ERROR in Test.java (at line 20)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 23)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1803,15 +1790,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1910,15 +1897,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -1975,7 +1962,7 @@ "1. ERROR in Test.java (at line 2)\n" + " * @see Unrelated1#add(Object)\n" + " ^^^\n" + - "Javadoc: The method add(Object) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Object)\n" + "----------\n" + "2. ERROR in Test.java (at line 3)\n" + " * @see Unrelated1#Unrelated1(Object)\n" + @@ -2017,15 +2004,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 16)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 17)\n" + + "10. ERROR in Test.java (at line 17)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 20)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2062,76 +2049,76 @@ "}\n" }, "----------\n" + - "1. ERROR in Unrelated1.java (at line 1)\r\n" + - " public class Unrelated1 {\r\n" + + "1. ERROR in Unrelated1.java (at line 1)\n" + + " public class Unrelated1 {\n" + " ^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "2. ERROR in Unrelated1.java (at line 2)\r\n" + - " public Unrelated1(E e) {}\r\n" + + "2. ERROR in Unrelated1.java (at line 2)\n" + + " public Unrelated1(E e) {}\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "3. ERROR in Unrelated1.java (at line 3)\r\n" + - " public boolean add(E e) { return false; }\r\n" + + "3. ERROR in Unrelated1.java (at line 3)\n" + + " public boolean add(E e) { return false; }\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + "----------\n" + - "1. ERROR in Test.java (at line 2)\r\n" + - " * @see Unrelated1#add(Number)\r\n" + + "1. ERROR in Test.java (at line 2)\n" + + " * @see Unrelated1#add(Number)\n" + " ^^^\n" + - "Javadoc: The method add(Number) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Number)\n" + "----------\n" + - "2. ERROR in Test.java (at line 3)\r\n" + - " * @see Unrelated1#Unrelated1(Number)\r\n" + + "2. ERROR in Test.java (at line 3)\n" + + " * @see Unrelated1#Unrelated1(Number)\n" + " ^^^^^^^^^^^^^^^^^^\n" + "Javadoc: The constructor Unrelated1(Number) is undefined\n" + "----------\n" + - "3. ERROR in Test.java (at line 8)\r\n" + - " public class Test{\r\n" + + "3. ERROR in Test.java (at line 8)\n" + + " public class Test{\n" + " ^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "4. ERROR in Test.java (at line 9)\r\n" + - " Test(T t) {}\r\n" + + "4. ERROR in Test.java (at line 9)\n" + + " Test(T t) {}\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "5. ERROR in Test.java (at line 10)\r\n" + - " public boolean add(T t) {\r\n" + + "5. ERROR in Test.java (at line 10)\n" + + " public boolean add(T t) {\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "6. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "6. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^^^^^^^^^^^^^^^^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "7. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "7. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^\n" + "Syntax error, parameterized types are only available if source level is 5.0\n" + "----------\n" + - "8. ERROR in Test.java (at line 14)\r\n" + - " class Sub extends Test {\r\n" + + "8. ERROR in Test.java (at line 14)\n" + + " class Sub extends Test {\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "9. ERROR in Test.java (at line 15)\r\n" + - " Sub (E e) {super(null);}\r\n" + + "9. ERROR in Test.java (at line 15)\n" + + " Sub (E e) {super(null);}\n" + " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 15)\r\n" + - " Sub (E e) {super(null);}\r\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 16)\r\n" + - " public boolean add(E e) {\r\n" + + "10. ERROR in Test.java (at line 16)\n" + + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 19)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2189,7 +2176,7 @@ "1. ERROR in Test.java (at line 2)\n" + " * @see Unrelated1#add(Integer)\n" + " ^^^\n" + - "Javadoc: The method add(Integer) is undefined for the type Unrelated1\n" + + "Javadoc: The method add(E) in the type Unrelated1 is not applicable for the arguments (Integer)\n" + "----------\n" + "2. ERROR in Test.java (at line 3)\n" + " * @see Unrelated1#Unrelated1(Integer)\n" + @@ -2231,15 +2218,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "10. ERROR in Test.java (at line 17)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "11. ERROR in Test.java (at line 18)\n" + + "10. ERROR in Test.java (at line 18)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "11. ERROR in Test.java (at line 21)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -2329,15 +2316,15 @@ " ^\n" + "E cannot be resolved to a type\n" + "----------\n" + - "9. ERROR in Test.java (at line 18)\n" + - " Sub (E e) {super(null);}\n" + - " ^^^^^^^^^^^^\n" + - "The constructor Object(null) is undefined\n" + - "----------\n" + - "10. ERROR in Test.java (at line 19)\n" + + "9. ERROR in Test.java (at line 19)\n" + " public boolean add(E e) {\n" + " ^\n" + "E cannot be resolved to a type\n" + + "----------\n" + + "10. ERROR in Test.java (at line 22)\n" + + " return super.add(e);\n" + + " ^^^\n" + + "The method add(T) in the type Test is not applicable for the arguments (E)\n" + "----------\n" ); } @@ -3701,27 +3688,17 @@ "}\n" }, "----------\n" + - "1. ERROR in Test.java (at line 3)\n" + - " * @see Test#field\n" + - " ^^^^^\n" + - "Javadoc: field cannot be resolved or is not a field\n" + - "----------\n" + - "2. ERROR in Test.java (at line 4)\n" + - " * @see Test#foo()\n" + - " ^^^\n" + - "Javadoc: The method foo() is undefined for the type Test\n" + - "----------\n" + - "3. ERROR in Test.java (at line 6)\n" + + "1. ERROR in Test.java (at line 6)\n" + " public class Test {\n" + " ^\n" + "Syntax error, type parameters are only available if source level is 5.0\n" + "----------\n" + - "4. ERROR in Test.java (at line 7)\n" + + "2. ERROR in Test.java (at line 7)\n" + " T field;\n" + " ^\n" + "T cannot be resolved to a type\n" + "----------\n" + - "5. ERROR in Test.java (at line 8)\n" + + "3. ERROR in Test.java (at line 8)\n" + " T foo() { return null; }\n" + " ^\n" + "T cannot be resolved to a type\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v retrieving revision 1.70 diff -u -r1.70 LookupTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 16 Oct 2007 10:24:51 -0000 1.70 +++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 28 Nov 2007 18:11:58 -0000 @@ -1819,22 +1819,26 @@ "}\n", }, "----------\n" + - "1. ERROR in A.java (at line 4)\r\n" + - " B b = new B();\r\n" + + "1. ERROR in A.java (at line 4)\n" + + " B b = new B();\n" + " ^\n" + "The type B is not visible\n" + "----------\n" + - "2. ERROR in A.java (at line 4)\r\n" + - " B b = new B();\r\n" + + "2. ERROR in A.java (at line 4)\n" + + " B b = new B();\n" + " ^\n" + "The type B is not visible\n" + "----------\n" + - "3. ERROR in A.java (at line 6)\r\n" + - " String s2 = B.str;\r\n" + + "3. ERROR in A.java (at line 5)\n" + + " String s1 = b.str;\n" + + " ^^^^^\n" + + "The type B is not visible\n" + + "----------\n" + + "4. ERROR in A.java (at line 6)\n" + + " String s2 = B.str;\n" + " ^\n" + "The type B is not visible\n" + - "----------\n" - ); + "----------\n"); } // final method in static inner class still found in extending classes public void test056() { @@ -1936,11 +1940,6 @@ " Zork bb() {\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + - "----------\n" + - "2. ERROR in X.java (at line 10)\n" + - " this.bb();\n" + - " ^^\n" + - "The method bb() is undefined for the type X\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=132813 - variation @@ -1974,11 +1973,6 @@ " Zork bb() {\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + - "----------\n" + - "3. ERROR in X.java (at line 10)\n" + - " this.bb();\n" + - " ^^\n" + - "The method bb() is undefined for the type X\n" + "----------\n"); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=134839 Index: src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java,v retrieving revision 1.94 diff -u -r1.94 Compliance_1_3.java --- src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java 2 Nov 2007 12:22:52 -0000 1.94 +++ src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java 28 Nov 2007 18:11:52 -0000 @@ -1278,10 +1278,20 @@ " ^^^^^^^\n" + "The type Homonym is defined in an inherited type and an enclosing scope\n" + "----------\n" + - "3. ERROR in X.java (at line 13)\n" + + "3. ERROR in X.java (at line 6)\n" + + " class Y extends Homonym {}; \n" + + " ^^^^^^^\n" + + "The type X.Homonym cannot be the superclass of Y; a superclass must be a class\n" + + "----------\n" + + "4. ERROR in X.java (at line 13)\n" + " class Y extends Homonym {}; \n" + " ^^^^^^^\n" + "The type Homonym is defined in an inherited type and an enclosing scope\n" + + "----------\n" + + "5. ERROR in X.java (at line 13)\n" + + " class Y extends Homonym {}; \n" + + " ^^^^^^^\n" + + "The type X.Homonym cannot be the superclass of Y; a superclass must be a class\n" + "----------\n"); } /* #P org.eclipse.jdt.core.tests Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/FromJikesPRs.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/FromJikesPRs.java,v retrieving revision 1.25 diff -u -r1.25 FromJikesPRs.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/FromJikesPRs.java 6 Mar 2007 04:29:57 -0000 1.25 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/FromJikesPRs.java 28 Nov 2007 18:12:03 -0000 @@ -335,12 +335,7 @@ "} \n" }, "----------\n" + - "1. WARNING in Outer.java (at line 2)\n" + - " private class Inner {} \n" + - " ^^^^^\n" + - "The type Outer.Inner is never used locally\n" + - "----------\n" + - "2. ERROR in Outer.java (at line 4)\n" + + "1. ERROR in Outer.java (at line 4)\n" + " new Outer(){}.new Inner(){}; \n" + " ^^^^^\n" + "The type Outer.Inner is not visible\n" + Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InnerClassTest.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InnerClassTest.java,v retrieving revision 1.40 diff -u -r1.40 InnerClassTest.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InnerClassTest.java 16 Oct 2007 10:24:34 -0000 1.40 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InnerClassTest.java 28 Nov 2007 18:12:06 -0000 @@ -7688,8 +7688,12 @@ " A.E ae = new A().new A.E();\n" + " ^\n" + "A cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n" + + "3. ERROR in InnerClassTests\\PassingParameters\\Test05.java (at line 5)\n" + + " System.out.println( ae.varE );\n" + + " ^^^^^^^\n" + + "ae.varE cannot be resolved or is not a field\n" + + "----------\n"); } public void test163() { this.runConformTest(new String[] { Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java,v retrieving revision 1.307 diff -u -r1.307 NegativeTest.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 8 Nov 2007 16:28:45 -0000 1.307 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 28 Nov 2007 18:12:08 -0000 @@ -3803,8 +3803,7 @@ " int t = new Test1xHelp().x;\n" + " ^^^^^^^^^^\n" + "Test1xHelp cannot be resolved to a type\n" + - "----------\n" - ); + "----------\n"); } public void test096() { this.runNegativeTest( @@ -6140,17 +6139,27 @@ " ^^^^\n" + "Zork cannot be resolved to a type\n" + "----------\n" + - "2. ERROR in p\\AJB.java (at line 15)\n" + + "2. ERROR in p\\AJB.java (at line 10)\n" + + " z.foo.bar.zork();\n" + + " ^^^^^\n" + + "z.foo cannot be resolved or is not a field\n" + + "----------\n" + + "3. ERROR in p\\AJB.java (at line 11)\n" + + " zork(z.foo);\n" + + " ^^^^^\n" + + "z.foo cannot be resolved or is not a field\n" + + "----------\n" + + "4. ERROR in p\\AJB.java (at line 15)\n" + " void bar(Zork x){\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + "----------\n" + - "3. ERROR in p\\AJB.java (at line 16)\n" + + "5. ERROR in p\\AJB.java (at line 16)\n" + " Object x = z;\n" + " ^\n" + "Duplicate local variable x\n" + "----------\n" + - "4. ERROR in p\\AJB.java (at line 16)\n" + + "6. ERROR in p\\AJB.java (at line 16)\n" + " Object x = z;\n" + " ^\n" + "Cannot refer to a non-final variable z inside an inner class defined in a different method\n" + @@ -8772,20 +8781,12 @@ "}", }, - "----------\n" + - "1. ERROR in p\\k\\ExtendsA.java (at line 4)\n" + - " int i = new AA().new Inner().i; // THIS LINE SHOULD CAUSE AN ERROR\n" + - " ^^^^^\n" + - "The type AA.Inner is not visible\n" + - "----------\n" + - "----------\n" + - "1. WARNING in p\\k\\AA.java (at line 3)\n" + - " private class Inner {\n" + - " ^^^^^\n" + - "The type AA.Inner is never used locally\n" + - "----------\n" - - ); + "----------\n" + + "1. ERROR in p\\k\\ExtendsA.java (at line 4)\n" + + " int i = new AA().new Inner().i; // THIS LINE SHOULD CAUSE AN ERROR\n" + + " ^^^^^\n" + + "The type AA.Inner is not visible\n" + + "----------\n" ); } public void test227() { this.runNegativeTest( @@ -10043,6 +10044,11 @@ " int foo(Zork z){ \n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " return z.i; \n" + + " ^^^\n" + + "z.i cannot be resolved or is not a field\n" + "----------\n"); } @@ -11902,12 +11908,6 @@ "} \n", }, "----------\n" + - "1. WARNING in p\\X.java (at line 3)\n" + - " private class Y { \n" + - " ^\n" + - "The type X.Y is never used locally\n" + - "----------\n" + - "----------\n" + "1. ERROR in q\\Y.java (at line 2)\n" + " import p.X.Y.Z; \n" + " ^^^^^\n" + @@ -12124,27 +12124,22 @@ "} \n", }, "----------\n" + - "1. WARNING in X.java (at line 2)\n" + - " private class M {} \n" + - " ^\n" + - "The type X.M is never used locally\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + + "1. WARNING in X.java (at line 3)\n" + " private int f; \n" + " ^\n" + "The field X.f is never read locally\n" + "----------\n" + - "3. ERROR in X.java (at line 6)\n" + + "2. ERROR in X.java (at line 6)\n" + " int y = new X().f; \n" + " ^\n" + "The field X.f is not visible\n" + "----------\n" + - "4. ERROR in X.java (at line 7)\n" + + "3. ERROR in X.java (at line 7)\n" + " X.M xm = new X().new M(); \n" + " ^^^\n" + "The type X.M is not visible\n" + "----------\n" + - "5. ERROR in X.java (at line 7)\n" + + "4. ERROR in X.java (at line 7)\n" + " X.M xm = new X().new M(); \n" + " ^\n" + "The type X.M is not visible\n" + @@ -12170,37 +12165,32 @@ "} \n", }, "----------\n" + - "1. WARNING in X.java (at line 2)\n" + - " private class M { \n" + - " ^\n" + - "The type X.M is never used locally\n" + - "----------\n" + - "2. WARNING in X.java (at line 3)\n" + + "1. WARNING in X.java (at line 3)\n" + " { X.this.foo(); } \n" + " ^^^^^^^^^^^^\n" + "Access to enclosing method foo() from the type X is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + "----------\n" + - "3. WARNING in X.java (at line 4)\n" + + "2. WARNING in X.java (at line 4)\n" + " { X.this.f++; } \n" + " ^\n" + "Read access to enclosing field X.f is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + "----------\n" + - "4. WARNING in X.java (at line 4)\n" + + "3. WARNING in X.java (at line 4)\n" + " { X.this.f++; } \n" + " ^\n" + "Write access to enclosing field X.f is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + "----------\n" + - "5. ERROR in X.java (at line 10)\n" + + "4. ERROR in X.java (at line 10)\n" + " int y = new X().f; \n" + " ^\n" + "The field X.f is not visible\n" + "----------\n" + - "6. ERROR in X.java (at line 11)\n" + + "5. ERROR in X.java (at line 11)\n" + " X.M xm = new X().new M(); \n" + " ^^^\n" + "The type X.M is not visible\n" + "----------\n" + - "7. ERROR in X.java (at line 11)\n" + + "6. ERROR in X.java (at line 11)\n" + " X.M xm = new X().new M(); \n" + " ^\n" + "The type X.M is not visible\n" + @@ -15791,6 +15781,11 @@ " Zork zork() {\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " return this;\n" + + " ^^^^\n" + + "Type mismatch: cannot convert from X to Zork\n" + "----------\n"); } /* #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v retrieving revision 1.121 diff -u -r1.121 ReconcilerTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 22 Nov 2007 11:24:41 -0000 1.121 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 28 Nov 2007 18:12:09 -0000 @@ -2027,8 +2027,12 @@ this.workingCopy.open(null); assertProblems( "Unexpected problems", - "----------\n" + - "----------\n" // shouldn't report problem against p2.X01 + "----------\n" + + "1. ERROR in /Reconciler/src/p2/X01.java (at line 2)\n" + + " public class X01 extends p1.X01 {\n" + + " ^^^\n" + + "The type X01 must implement the inherited abstract method X01.foo(Zork)\n" + + "----------\n" ); } finally { deleteFile("/Reconciler/src/p1/X01.java"); @@ -3713,19 +3717,17 @@ this.problemRequestor.initialize(sourcesAsCharArrays[2]); this.workingCopies[2] = getCompilationUnit("/P3/Y.java").getWorkingCopy(this.wcOwner, null); assertProblems("Working copy should have problems:", - "----------\n" + - "1. ERROR in /P3/Y.java (at line 1)\n" + - " class Y implements I {\n" + - " ^\n" + -// we miss the first diagnostic - see justification in bugzilla -// "The type Y must implement the inherited abstract method I.bar(X)\n" + -// "----------\n" + -// "2. ERROR in /P3/Y.java (at line 1)\n" + -// " class Y implements I {\n" + -// " ^\n" + - "The type Y must implement the inherited abstract method I.foo()\n" + - "----------\n" - ); + "----------\n" + + "1. ERROR in /P3/Y.java (at line 1)\n" + + " class Y implements I {\n" + + " ^\n" + + "The type Y must implement the inherited abstract method I.bar(X)\n" + + "----------\n" + + "2. ERROR in /P3/Y.java (at line 1)\n" + + " class Y implements I {\n" + + " ^\n" + + "The type Y must implement the inherited abstract method I.foo()\n" + + "----------\n"); } finally { deleteProject("P1"); deleteProject("P2");