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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-1 / +29 lines)
Lines 144-150 Link Here
144
	return type;
144
	return type;
145
}
145
}
146
146
147
147
/**
148
 * Standard constructor for creating binary type bindings from binary models (classfiles)
149
 * @param packageBinding
150
 * @param binaryType
151
 * @param environment
152
 */
148
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
153
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
149
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
154
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
150
	computeId();
155
	computeId();
Lines 183-188 Link Here
183
	}	
188
	}	
184
}
189
}
185
190
191
/**
192
 * Special constructor for constructing proxies of missing binary types (114349)
193
 * @param packageBinding
194
 * @param compoundName
195
 * @param environment
196
 */
197
BinaryTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) {
198
	this.compoundName = compoundName;
199
	computeId();
200
	this.tagBits |= TagBits.IsBinaryBinding;
201
	this.environment = environment;
202
	this.fPackage = packageBinding;
203
	this.fileName = CharOperation.concatWith(compoundName, '/');
204
	this.sourceName = CharOperation.concatWith(compoundName, '.');
205
	this.modifiers = ClassFileConstants.AccPublic;
206
	this.superclass = null;
207
	this.superInterfaces = Binding.NO_SUPERINTERFACES;
208
	this.typeVariables = Binding.NO_TYPE_VARIABLES;
209
	this.memberTypes = Binding.NO_MEMBER_TYPES;
210
	this.fields = Binding.NO_FIELDS;
211
	this.methods = Binding.NO_METHODS;
212
}
213
186
public FieldBinding[] availableFields() {
214
public FieldBinding[] availableFields() {
187
	if ((this.tagBits & TagBits.AreFieldsComplete) != 0)
215
	if ((this.tagBits & TagBits.AreFieldsComplete) != 0)
188
		return fields;
216
		return fields;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-5 / +29 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.internal.compiler.ClassFilePool;
17
import org.eclipse.jdt.internal.compiler.ClassFilePool;
18
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
18
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
19
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
19
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
20
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.env.*;
22
import org.eclipse.jdt.internal.compiler.env.*;
Lines 64-70 Link Here
64
	private SimpleLookupTable uniqueParameterizedGenericMethodBindings;
65
	private SimpleLookupTable uniqueParameterizedGenericMethodBindings;
65
	
66
	
66
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
67
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
67
68
	public TypeReference superTypeReference; // only set while resolving certain type references
69
	
68
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
70
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
69
	private MethodVerifier verifier;
71
	private MethodVerifier verifier;
70
72
Lines 173-178 Link Here
173
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
175
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
174
	return null; // the type already exists & can be retrieved from the cache
176
	return null; // the type already exists & can be retrieved from the cache
175
}
177
}
178
179
public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName) {
180
	PackageBinding packageBinding = getPackage0(compoundName[0]);
181
	if (packageBinding == null || packageBinding == TheNotFoundPackage) {
182
		packageBinding = new PackageBinding(compoundName[0], this);
183
		knownPackages.put(compoundName[0], packageBinding);
184
	}
185
	for (int i = 1, packageLength = compoundName.length - 1; i < packageLength; i++) {
186
		PackageBinding subPackageBinding = packageBinding.getPackage0(compoundName[i]);
187
		if (subPackageBinding == null || subPackageBinding == TheNotFoundPackage) {
188
			char[][] subName = CharOperation.subarray(compoundName, 0, i + 1);
189
			subPackageBinding = new PackageBinding(subName, packageBinding, this);
190
			packageBinding.addPackage(subPackageBinding);
191
			packageBinding = subPackageBinding;
192
		}
193
	}
194
	// create a proxy for the missing BinaryType
195
	BinaryTypeBinding type = new BinaryTypeBinding(packageBinding, compoundName, this);
196
	packageBinding.addType(type);
197
	return type;	
198
}
176
/*
199
/*
177
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
200
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
178
* 2. Create the field bindings
201
* 2. Create the field bindings
Lines 859-866 Link Here
859
	ReferenceBinding type = getType(compoundName);
882
	ReferenceBinding type = getType(compoundName);
860
	if (type != null) return type;
883
	if (type != null) return type;
861
884
862
	problemReporter.isClassPathCorrect(compoundName, scope == null ? null : scope.referenceCompilationUnit());
885
	problemReporter.isClassPathCorrect(compoundName, scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit(), this.superTypeReference);
863
	return null; // will not get here since the above error aborts the compilation
886
	return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
864
}
887
}
865
/* Answer the top level package named name.
888
/* Answer the top level package named name.
866
* Ask the oracle for the package if its not in the cache.
889
* Ask the oracle for the package if its not in the cache.
Lines 957-970 Link Here
957
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
980
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
958
		packageBinding.addType(binding);
981
		packageBinding.addType(binding);
959
	} else if (binding == TheNotFoundType) {
982
	} else if (binding == TheNotFoundType) {
960
		problemReporter.isClassPathCorrect(compoundName, null);
983
		problemReporter.isClassPathCorrect(compoundName, this.unitBeingCompleted, this.superTypeReference);
961
		return null; // will not get here since the above error aborts the compilation
984
		return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
962
	} else if (!isParameterized) {
985
	} else if (!isParameterized) {
963
	    // check raw type, only for resolved types
986
	    // check raw type, only for resolved types
964
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
987
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
965
	}
988
	}
966
	return binding;
989
	return binding;
967
}
990
}
991
968
/* Answer the type corresponding to the name from the binary file.
992
/* Answer the type corresponding to the name from the binary file.
969
* Does not ask the oracle for the type if its not found in the cache... instead an
993
* Does not ask the oracle for the type if its not found in the cache... instead an
970
* unresolved type is returned which must be resolved before used.
994
* unresolved type is returned which must be resolved before used.
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-2 / +5 lines)
Lines 550-558 Link Here
550
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
550
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
551
551
552
	// abort if java.lang cannot be found...
552
	// abort if java.lang cannot be found...
553
	if (importBinding == null || !importBinding.isValidBinding())
553
	if (importBinding == null || !importBinding.isValidBinding()) {
554
		problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
554
		problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit(), null);
555
		BinaryTypeBinding missingObject = environment.cacheMissingBinaryType(JAVA_LANG_OBJECT);	// create a proxy for the missing BinaryType
556
		importBinding = missingObject.fPackage;
555
557
558
	}
556
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
559
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
557
}
560
}
558
// NOT Public API
561
// NOT Public API
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java (-5 / +4 lines)
Lines 41-52 Link Here
41
		targetType = this.fPackage.getType0(this.compoundName[this.compoundName.length - 1]);
41
		targetType = this.fPackage.getType0(this.compoundName[this.compoundName.length - 1]);
42
		if (targetType == this)
42
		if (targetType == this)
43
			targetType = environment.askForType(this.compoundName);
43
			targetType = environment.askForType(this.compoundName);
44
		if (targetType != null && targetType != this) { // could not resolve any better, error was already reported against it
44
		if (targetType == null || targetType == this) { // could not resolve any better, error was already reported against it
45
			setResolvedType(targetType, environment);
45
			environment.problemReporter.isClassPathCorrect(this.compoundName, environment.unitBeingCompleted, environment.superTypeReference);
46
		} else {
46
			targetType = environment.cacheMissingBinaryType(this.compoundName);	// create a proxy for the missing BinaryType
47
			environment.problemReporter.isClassPathCorrect(this.compoundName, null);
48
			return null; // will not get here since the above error aborts the compilation
49
		}
47
		}
48
		setResolvedType(targetType, environment);
50
	}
49
	}
51
	if (convertGenericToRawType) {
50
	if (convertGenericToRawType) {
52
		targetType = (ReferenceBinding) environment.convertUnresolvedBinaryToRawType(targetType);
51
		targetType = (ReferenceBinding) environment.convertUnresolvedBinaryToRawType(targetType);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-6 / +8 lines)
Lines 30-36 Link Here
30
public class ClassScope extends Scope {
30
public class ClassScope extends Scope {
31
	
31
	
32
	public TypeDeclaration referenceContext;
32
	public TypeDeclaration referenceContext;
33
	public TypeReference superTypeReference;
34
33
35
	public ClassScope(Scope parent, TypeDeclaration context) {
34
	public ClassScope(Scope parent, TypeDeclaration context) {
36
		super(CLASS_SCOPE, parent);
35
		super(CLASS_SCOPE, parent);
Lines 991-997 Link Here
991
	public boolean detectHierarchyCycle(TypeBinding superType, TypeReference reference, TypeBinding[] argTypes) {
990
	public boolean detectHierarchyCycle(TypeBinding superType, TypeReference reference, TypeBinding[] argTypes) {
992
		if (!(superType instanceof ReferenceBinding)) return false;
991
		if (!(superType instanceof ReferenceBinding)) return false;
993
992
994
		if (reference == this.superTypeReference) { // see findSuperType()
993
		if (reference == environment().superTypeReference) { // see findSuperType()
995
			if (superType.isTypeVariable())
994
			if (superType.isTypeVariable())
996
				return false; // error case caught in resolveSuperType()
995
				return false; // error case caught in resolveSuperType()
997
			// abstract class X<K,V> implements java.util.Map<K,V>
996
			// abstract class X<K,V> implements java.util.Map<K,V>
Lines 1078-1084 Link Here
1078
		}
1077
		}
1079
1078
1080
		if (superType.isHierarchyBeingConnected()) {
1079
		if (superType.isHierarchyBeingConnected()) {
1081
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = ((SourceTypeBinding) superType).scope.superTypeReference;
1080
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = environment().superTypeReference;
1082
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1081
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1083
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1082
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1084
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingConnected())) {
1083
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingConnected())) {
Lines 1097-1115 Link Here
1097
	}
1096
	}
1098
1097
1099
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1098
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1099
		LookupEnvironment environment = environment();
1100
		TypeReference keep = environment.superTypeReference;
1100
		try {
1101
		try {
1101
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1102
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1102
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1103
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1103
			this.superTypeReference = typeReference;
1104
			environment.superTypeReference = typeReference;
1104
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1105
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1105
			this.superTypeReference = null;
1106
			return superType;
1106
			return superType;
1107
		} catch (AbortCompilation e) {
1107
		} catch (AbortCompilation e) {
1108
			SourceTypeBinding sourceType = this.referenceContext.binding;
1108
			SourceTypeBinding sourceType = this.referenceContext.binding;
1109
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1109
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1110
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1110
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1111
			throw e;
1111
			throw e;
1112
		}			
1112
		} finally {
1113
			environment.superTypeReference = keep;
1114
		}
1113
	}
1115
	}
1114
1116
1115
	/* Answer the problem reporter to use for raising new problems.
1117
	/* Answer the problem reporter to use for raising new problems.
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-5 / +4 lines)
Lines 3387-3402 Link Here
3387
		argument.type.sourceStart,
3387
		argument.type.sourceStart,
3388
		argument.sourceEnd);
3388
		argument.sourceEnd);
3389
}
3389
}
3390
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3390
public void isClassPathCorrect(char[][] expectedTypeName, CompilationUnitDeclaration compUnitDecl, ASTNode location) {
3391
	this.referenceContext = compUnitDecl;
3391
	this.referenceContext = compUnitDecl;
3392
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3392
	String[] arguments = new String[] {CharOperation.toString(expectedTypeName)};
3393
	this.handle(
3393
	this.handle(
3394
		IProblem.IsClassPathCorrect,
3394
		IProblem.IsClassPathCorrect,
3395
		arguments, 
3395
		arguments, 
3396
		arguments,
3396
		arguments,
3397
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3397
		location == null ? 0 : location.sourceStart(),
3398
		0,
3398
		location == null ? 0 : location.sourceEnd());
3399
		0);
3400
}
3399
}
3401
private boolean isIdentifier(int token) {
3400
private boolean isIdentifier(int token) {
3402
	return token == TerminalTokens.TokenNameIdentifier;
3401
	return token == TerminalTokens.TokenNameIdentifier;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-7 / +8 lines)
Lines 94-99 Link Here
94
				return null; // already reported error
94
				return null; // already reported error
95
			return this.resolvedType;
95
			return this.resolvedType;
96
		} 
96
		} 
97
		LookupEnvironment environment = scope.environment();
97
	    this.didResolve = true;
98
	    this.didResolve = true;
98
		if (enclosingType == null) {
99
		if (enclosingType == null) {
99
			this.resolvedType = scope.getType(token);
100
			this.resolvedType = scope.getType(token);
Lines 105-112 Link Here
105
			if (enclosingType != null && (enclosingType.isGenericType() || enclosingType.isParameterizedType())) {
106
			if (enclosingType != null && (enclosingType.isGenericType() || enclosingType.isParameterizedType())) {
106
				ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
107
				ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
107
				enclosingType = currentType.isStatic()
108
				enclosingType = currentType.isStatic()
108
					? (ReferenceBinding) scope.environment().convertToRawType(enclosingType)
109
					? (ReferenceBinding) environment.convertToRawType(enclosingType)
109
					: scope.environment().convertToParameterizedType(enclosingType);
110
					: environment.convertToParameterizedType(enclosingType);
110
			}
111
			}
111
		} else { // resolving member type (relatively to enclosingType)
112
		} else { // resolving member type (relatively to enclosingType)
112
			this.resolvedType = scope.getMemberType(token, (ReferenceBinding)enclosingType.erasure());		    
113
			this.resolvedType = scope.getMemberType(token, (ReferenceBinding)enclosingType.erasure());		    
Lines 122-129 Link Here
122
	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
123
	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
123
	    TypeReference keep = null;
124
	    TypeReference keep = null;
124
	    if (isClassScope) {
125
	    if (isClassScope) {
125
	    	keep = ((ClassScope) scope).superTypeReference;
126
	    	keep = environment.superTypeReference;
126
	    	((ClassScope) scope).superTypeReference = null;
127
	    	environment.superTypeReference = null;
127
	    }
128
	    }
128
		ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
129
		ReferenceBinding currentType = (ReferenceBinding) this.resolvedType;
129
		int argLength = this.typeArguments.length;
130
		int argLength = this.typeArguments.length;
Lines 142-148 Link Here
142
		}
143
		}
143
		if (argHasError) return null;
144
		if (argHasError) return null;
144
		if (isClassScope) {
145
		if (isClassScope) {
145
	    	((ClassScope) scope).superTypeReference = keep;
146
			environment.superTypeReference = keep;
146
			if (((ClassScope) scope).detectHierarchyCycle(currentType, this, argTypes))
147
			if (((ClassScope) scope).detectHierarchyCycle(currentType, this, argTypes))
147
				return null;
148
				return null;
148
		}
149
		}
Lines 156-166 Link Here
156
			return null;
157
			return null;
157
		} else if (!currentType.isStatic() && enclosingType != null && enclosingType.isRawType()){
158
		} else if (!currentType.isStatic() && enclosingType != null && enclosingType.isRawType()){
158
			scope.problemReporter().rawMemberTypeCannotBeParameterized(
159
			scope.problemReporter().rawMemberTypeCannotBeParameterized(
159
					this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), enclosingType), argTypes);
160
					this, environment.createRawType((ReferenceBinding)currentType.erasure(), enclosingType), argTypes);
160
			return null;
161
			return null;
161
		}
162
		}
162
163
163
    	ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, enclosingType);
164
    	ParameterizedTypeBinding parameterizedType = environment.createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, enclosingType);
164
		// check argument type compatibility
165
		// check argument type compatibility
165
		if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
166
		if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
166
			parameterizedType.boundCheck(scope, this.typeArguments);
167
			parameterizedType.boundCheck(scope, this.typeArguments);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-11 / +12 lines)
Lines 129-134 Link Here
129
	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
129
	    boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
130
		boolean typeIsConsistent = true;
130
		boolean typeIsConsistent = true;
131
		ReferenceBinding qualifiedType = null;
131
		ReferenceBinding qualifiedType = null;
132
		LookupEnvironment environment = scope.environment();
132
	    for (int i = packageBinding == null ? 0 : packageBinding.compoundName.length, max = this.tokens.length; i < max; i++) {
133
	    for (int i = packageBinding == null ? 0 : packageBinding.compoundName.length, max = this.tokens.length; i < max; i++) {
133
			findNextTypeBinding(i, scope, packageBinding);
134
			findNextTypeBinding(i, scope, packageBinding);
134
			if (!(this.resolvedType.isValidBinding())) {
135
			if (!(this.resolvedType.isValidBinding())) {
Lines 140-151 Link Here
140
				qualifiedType = currentType.enclosingType(); // if member type
141
				qualifiedType = currentType.enclosingType(); // if member type
141
				if (qualifiedType != null && (qualifiedType.isGenericType() || qualifiedType.isParameterizedType())) {
142
				if (qualifiedType != null && (qualifiedType.isGenericType() || qualifiedType.isParameterizedType())) {
142
					qualifiedType = currentType.isStatic()
143
					qualifiedType = currentType.isStatic()
143
						? (ReferenceBinding) scope.environment().convertToRawType(qualifiedType)
144
						? (ReferenceBinding) environment.convertToRawType(qualifiedType)
144
						: scope.environment().convertToParameterizedType(qualifiedType);
145
						: environment.convertToParameterizedType(qualifiedType);
145
				}
146
				}
146
			}				
147
			}				
147
			if (typeIsConsistent && currentType.isStatic() && qualifiedType != null && (qualifiedType.isParameterizedType() || qualifiedType.isGenericType())) {
148
			if (typeIsConsistent && currentType.isStatic() && qualifiedType != null && (qualifiedType.isParameterizedType() || qualifiedType.isGenericType())) {
148
				scope.problemReporter().staticMemberOfParameterizedType(this, scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), null, qualifiedType));
149
				scope.problemReporter().staticMemberOfParameterizedType(this, environment.createParameterizedType((ReferenceBinding)currentType.erasure(), null, qualifiedType));
149
				typeIsConsistent = false;
150
				typeIsConsistent = false;
150
			}			
151
			}			
151
			// check generic and arity
152
			// check generic and arity
Lines 153-160 Link Here
153
		    if (args != null) {
154
		    if (args != null) {
154
			    TypeReference keep = null;
155
			    TypeReference keep = null;
155
			    if (isClassScope) {
156
			    if (isClassScope) {
156
			    	keep = ((ClassScope) scope).superTypeReference;
157
			    	keep = environment.superTypeReference;
157
			    	((ClassScope) scope).superTypeReference = null;
158
			    	environment.superTypeReference = null;
158
			    }
159
			    }
159
				int argLength = args.length;
160
				int argLength = args.length;
160
				TypeBinding[] argTypes = new TypeBinding[argLength];
161
				TypeBinding[] argTypes = new TypeBinding[argLength];
Lines 174-180 Link Here
174
					return null;
175
					return null;
175
				}
176
				}
176
				if (isClassScope) {
177
				if (isClassScope) {
177
					((ClassScope) scope).superTypeReference = keep;
178
					environment.superTypeReference = keep;
178
					if (((ClassScope) scope).detectHierarchyCycle(currentType, this, argTypes))
179
					if (((ClassScope) scope).detectHierarchyCycle(currentType, this, argTypes))
179
						return null;
180
						return null;
180
				}
181
				}
Lines 190-199 Link Here
190
				// check parameterizing non-static member type of raw type
191
				// check parameterizing non-static member type of raw type
191
				if (typeIsConsistent && !currentType.isStatic() && qualifiedType != null && qualifiedType.isRawType()) {
192
				if (typeIsConsistent && !currentType.isStatic() && qualifiedType != null && qualifiedType.isRawType()) {
192
					scope.problemReporter().rawMemberTypeCannotBeParameterized(
193
					scope.problemReporter().rawMemberTypeCannotBeParameterized(
193
							this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), qualifiedType), argTypes);
194
							this, environment.createRawType((ReferenceBinding)currentType.erasure(), qualifiedType), argTypes);
194
					typeIsConsistent = false;				
195
					typeIsConsistent = false;				
195
				}
196
				}
196
				ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, qualifiedType);
197
				ParameterizedTypeBinding parameterizedType = environment.createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, qualifiedType);
197
				// check argument type compatibility
198
				// check argument type compatibility
198
				if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
199
				if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
199
					parameterizedType.boundCheck(scope, args);
200
					parameterizedType.boundCheck(scope, args);
Lines 205-217 Link Here
205
				ReferenceBinding currentErasure = (ReferenceBinding)currentType.erasure();
206
				ReferenceBinding currentErasure = (ReferenceBinding)currentType.erasure();
206
				if (currentErasure.isGenericType()) {
207
				if (currentErasure.isGenericType()) {
207
	   			    if (typeIsConsistent && qualifiedType != null && qualifiedType.isParameterizedType()) {
208
	   			    if (typeIsConsistent && qualifiedType != null && qualifiedType.isParameterizedType()) {
208
						scope.problemReporter().parameterizedMemberTypeMissingArguments(this, scope.environment().createParameterizedType(currentErasure, null, qualifiedType));
209
						scope.problemReporter().parameterizedMemberTypeMissingArguments(this, environment.createParameterizedType(currentErasure, null, qualifiedType));
209
						typeIsConsistent = false;
210
						typeIsConsistent = false;
210
					}
211
					}
211
	   			    qualifiedType = scope.environment().createRawType(currentErasure, qualifiedType); // raw type
212
	   			    qualifiedType = environment.createRawType(currentErasure, qualifiedType); // raw type
212
				} else {
213
				} else {
213
					qualifiedType = (qualifiedType != null && qualifiedType.isParameterizedType())
214
					qualifiedType = (qualifiedType != null && qualifiedType.isParameterizedType())
214
													? scope.environment().createParameterizedType(currentErasure, null, qualifiedType)
215
													? environment.createParameterizedType(currentErasure, null, qualifiedType)
215
													: currentType;
216
													: currentType;
216
				}
217
				}
217
			}
218
			}
(-)model/org/eclipse/jdt/internal/core/builder/MissingClassFileException.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.builder;
12
13
/**
14
 * Exception thrown when the build should be aborted because a referenced
15
 * class file cannot be found.
16
 */
17
public class MissingClassFileException extends RuntimeException {
18
19
	protected String missingClassFile;
20
	private static final long serialVersionUID = 3060418973806972616L; // backward compatible
21
22
public MissingClassFileException(String missingClassFile) {
23
	this.missingClassFile = missingClassFile;
24
}
25
}
(-)model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java (-10 / +27 lines)
Lines 50-55 Link Here
50
50
51
private boolean inCompiler;
51
private boolean inCompiler;
52
52
53
protected boolean keepStoringProblemMarkers;
53
protected SimpleSet filesWithAnnotations = null;
54
protected SimpleSet filesWithAnnotations = null;
54
55
55
public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed
56
public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed
Lines 84-89 Link Here
84
	this.nameEnvironment = javaBuilder.nameEnvironment;
85
	this.nameEnvironment = javaBuilder.nameEnvironment;
85
	this.sourceLocations = this.nameEnvironment.sourceLocations;
86
	this.sourceLocations = this.nameEnvironment.sourceLocations;
86
	this.notifier = javaBuilder.notifier;
87
	this.notifier = javaBuilder.notifier;
88
	this.keepStoringProblemMarkers = true; // may get disabled when missing classfiles are encountered
87
89
88
	if (buildStarting) {
90
	if (buildStarting) {
89
		this.newState = newState == null ? new State(javaBuilder) : newState;
91
		this.newState = newState == null ? new State(javaBuilder) : newState;
Lines 545-568 Link Here
545
 */
547
 */
546
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
548
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
547
	if (sourceFile == null || problems == null || problems.length == 0) return;
549
	if (sourceFile == null || problems == null || problems.length == 0) return;
550
	 // once a classpath error is found, ignore all other problems for this project so the user can see the main error
551
	// but still try to compile as many source files as possible to help the case when the base libraries are in source
552
	if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
548
553
549
	String missingClassFile = null;
550
	IResource resource = sourceFile.resource;
554
	IResource resource = sourceFile.resource;
551
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
555
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
552
	for (int i = 0, l = problems.length; i < l; i++) {
556
	for (int i = 0, l = problems.length; i < l; i++) {
553
		CategorizedProblem problem = problems[i];
557
		CategorizedProblem problem = problems[i];
554
		int id = problem.getID();
558
		int id = problem.getID();
559
		
560
		// handle missing classfile situation
555
		if (id == IProblem.IsClassPathCorrect) {
561
		if (id == IProblem.IsClassPathCorrect) {
556
			JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
562
			String missingClassfileName = problem.getArguments()[0];
557
			String[] args = problem.getArguments();
563
			if (JavaBuilder.DEBUG)
558
			missingClassFile = args[0];
564
				System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
565
			boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
566
			// insert extra classpath problem, and make it the only problem for this project (optional)
567
			if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
568
				JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
569
				this.keepStoringProblemMarkers = false;
570
			}
571
			IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
572
			marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); 
573
			marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
574
			marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
575
			// if not keeping more markers, still fall through rest of the problem reporting, so that offending IsClassPathCorrect 
576
			// problem gets recorded since it may help locating the offending reference
559
		}
577
		}
560
		
578
561
		String markerType = problem.getMarkerType();
579
		String markerType = problem.getMarkerType();
562
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
580
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) || managedMarkerTypes.contains(markerType)) {
563
				|| managedMarkerTypes.contains(markerType)) {			
564
			IMarker marker = resource.createMarker(markerType);
581
			IMarker marker = resource.createMarker(markerType);
565
			
582
566
			// standard attributes
583
			// standard attributes
567
			marker.setAttributes(
584
			marker.setAttributes(
568
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
585
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
Lines 583-591 Link Here
583
			if (extraLength > 0) {
600
			if (extraLength > 0) {
584
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
601
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
585
			}
602
			}
603
			
604
			if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
586
		}
605
		}
587
		if (missingClassFile != null)
588
			throw new MissingClassFileException(missingClassFile);
589
	}
606
	}
590
}
607
}
591
608
(-)model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java (-8 lines)
Lines 209-222 Link Here
209
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
209
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
210
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
210
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
211
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
211
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
212
	} catch (MissingClassFileException e) {
213
		// do not log this exception since its thrown to handle aborted compiles because of missing class files
214
		if (DEBUG)
215
			System.out.println(Messages.bind(Messages.build_incompleteClassPath, e.missingClassFile)); 
216
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
217
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, e.missingClassFile)); 
218
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
219
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
220
	} catch (MissingSourceFileException e) {
212
	} catch (MissingSourceFileException e) {
221
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
213
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
222
		if (DEBUG)
214
		if (DEBUG)
(-)src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java (+172 lines)
Lines 780-785 Link Here
780
		}
780
		}
781
	}
781
	}
782
	
782
	
783
//	 https://bugs.eclipse.org/bugs/show_bug.cgi?id=114349
784
//	 this one fails; compare with testCycle7 (only one change in Object source),
785
//	 which passes
786
	public void testCycle6() throws JavaModelException {
787
		Hashtable options = JavaCore.getOptions();
788
		Hashtable newOptions = JavaCore.getOptions();
789
		newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);
790
		
791
		JavaCore.setOptions(newOptions);
792
		
793
		//----------------------------
794
		//         Project1
795
		//----------------------------
796
		IPath p1 = env.addProject("P1");
797
		// remove old package fragment root so that names don't collide
798
		env.removePackageFragmentRoot(p1, "");
799
		IPath root1 = env.addPackageFragmentRoot(p1, "src");
800
		env.setOutputFolder(p1, "bin");
801
		
802
		env.addClass(root1, "java/lang", "Object",
803
			"package java.lang;\n" +
804
			"public class Object {\n" +
805
			"  Class getClass() { return null; }\n" +
806
			"  String toString() { return \"\"; }\n" +	// the line that changes
807
			"}\n"
808
			);
809
			
810
		//----------------------------
811
		//         Project2
812
		//----------------------------
813
		IPath p2 = env.addProject("P2");
814
		// remove old package fragment root so that names don't collide
815
		env.removePackageFragmentRoot(p2, "");
816
		IPath root2 = env.addPackageFragmentRoot(p2, "src");
817
		env.setOutputFolder(p2, "bin");
818
		
819
		env.addClass(root2, "java/lang", "Class",
820
			"package java.lang;\n" +
821
			"public class Class {\n" +
822
			"  String getName() { return \"\"; };\n" +
823
			"}\n"
824
			);
825
826
		//----------------------------
827
		//         Project3
828
		//----------------------------
829
		IPath p3 = env.addProject("P3");
830
		// remove old package fragment root so that names don't collide
831
		env.removePackageFragmentRoot(p3, "");
832
		IPath root3 = env.addPackageFragmentRoot(p3, "src");
833
		env.setOutputFolder(p3, "bin");
834
		
835
		env.addClass(root3, "java/lang", "String",
836
			"package java.lang;\n" +
837
			"public class String {\n" +
838
			"}\n"
839
			);
840
841
		// Dependencies
842
		IPath[] accessiblePaths = new IPath[] {new Path("java/lang/*")};
843
		IPath[] forbiddenPaths = new IPath[] {new Path("**/*")};
844
		env.addRequiredProject(p1, p2, accessiblePaths, forbiddenPaths, false);
845
		env.addRequiredProject(p1, p3, accessiblePaths, forbiddenPaths, false);
846
		env.addRequiredProject(p2, p1, accessiblePaths, forbiddenPaths, false);
847
		env.addRequiredProject(p2, p3, accessiblePaths, forbiddenPaths, false);
848
		env.addRequiredProject(p3, p1, accessiblePaths, forbiddenPaths, false);
849
		env.addRequiredProject(p3, p2, accessiblePaths, forbiddenPaths, false);
850
851
		try {
852
			fullBuild();
853
854
			expectingOnlySpecificProblemsFor(p1,new Problem[]{
855
				new Problem("p1", "A cycle was detected in the build path of project: P1", p1, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
856
			});
857
			expectingOnlySpecificProblemsFor(p2,new Problem[]{
858
				new Problem("p2", "A cycle was detected in the build path of project: P2", p2, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
859
			});
860
			expectingOnlySpecificProblemsFor(p3,new Problem[]{
861
				new Problem("p3", "A cycle was detected in the build path of project: P3", p3, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
862
			});
863
			
864
		} finally {
865
			JavaCore.setOptions(options);
866
		}
867
	}
868
869
//	 https://bugs.eclipse.org/bugs/show_bug.cgi?id=114349
870
//	 this one passes; compare with testCycle6 (only one change in Object source),
871
//	 which fails
872
	public void testCycle7() throws JavaModelException {
873
		Hashtable options = JavaCore.getOptions();
874
		Hashtable newOptions = JavaCore.getOptions();
875
		newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);
876
		
877
		JavaCore.setOptions(newOptions);
878
		
879
		//----------------------------
880
		//         Project1
881
		//----------------------------
882
		IPath p1 = env.addProject("P1");
883
		// remove old package fragment root so that names don't collide
884
		env.removePackageFragmentRoot(p1, "");
885
		IPath root1 = env.addPackageFragmentRoot(p1, "src");
886
		env.setOutputFolder(p1, "bin");
887
		
888
		env.addClass(root1, "java/lang", "Object",
889
			"package java.lang;\n" +
890
			"public class Object {\n" +
891
			"  Class getClass() { return null; }\n" +
892
			"  String toString() { return null; }\n" +	// the line that changes
893
			"}\n"
894
			);
895
			
896
		//----------------------------
897
		//         Project2
898
		//----------------------------
899
		IPath p2 = env.addProject("P2");
900
		// remove old package fragment root so that names don't collide
901
		env.removePackageFragmentRoot(p2, "");
902
		IPath root2 = env.addPackageFragmentRoot(p2, "src");
903
		env.setOutputFolder(p2, "bin");
904
		
905
		env.addClass(root2, "java/lang", "Class",
906
			"package java.lang;\n" +
907
			"public class Class {\n" +
908
			"  String getName() { return \"\"; };\n" +
909
			"}\n"
910
			);
911
912
		//----------------------------
913
		//         Project3
914
		//----------------------------
915
		IPath p3 = env.addProject("P3");
916
		// remove old package fragment root so that names don't collide
917
		env.removePackageFragmentRoot(p3, "");
918
		IPath root3 = env.addPackageFragmentRoot(p3, "src");
919
		env.setOutputFolder(p3, "bin");
920
		
921
		env.addClass(root3, "java/lang", "String",
922
			"package java.lang;\n" +
923
			"public class String {\n" +
924
			"}\n"
925
			);
926
927
		// Dependencies
928
		IPath[] accessiblePaths = new IPath[] {new Path("java/lang/*")};
929
		IPath[] forbiddenPaths = new IPath[] {new Path("**/*")};
930
		env.addRequiredProject(p1, p2, accessiblePaths, forbiddenPaths, false);
931
		env.addRequiredProject(p1, p3, accessiblePaths, forbiddenPaths, false);
932
		env.addRequiredProject(p2, p1, accessiblePaths, forbiddenPaths, false);
933
		env.addRequiredProject(p2, p3, accessiblePaths, forbiddenPaths, false);
934
		env.addRequiredProject(p3, p1, accessiblePaths, forbiddenPaths, false);
935
		env.addRequiredProject(p3, p2, accessiblePaths, forbiddenPaths, false);
936
937
		try {
938
			fullBuild();
939
940
			expectingOnlySpecificProblemsFor(p1,new Problem[]{
941
				new Problem("p1", "A cycle was detected in the build path of project: P1", p1, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
942
			});
943
			expectingOnlySpecificProblemsFor(p2,new Problem[]{
944
				new Problem("p2", "A cycle was detected in the build path of project: P2", p2, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
945
			});
946
			expectingOnlySpecificProblemsFor(p3,new Problem[]{
947
				new Problem("p3", "A cycle was detected in the build path of project: P3", p3, -1, -1, CategorizedProblem.CAT_BUILDPATH)//$NON-NLS-1$ //$NON-NLS-2$
948
			});
949
			
950
		} finally {
951
			JavaCore.setOptions(options);
952
		}
953
	}
954
	
783
	/*
955
	/*
784
	 * Full buid case
956
	 * Full buid case
785
	 */
957
	 */

Return to bug 114349