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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java (-1 / +1 lines)
Lines 783-789 Link Here
783
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=114349
783
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=114349
784
// this one fails; compare with testCycle7 (only one change in Object source),
784
// this one fails; compare with testCycle7 (only one change in Object source),
785
// which passes
785
// which passes
786
public void _testCycle6() throws JavaModelException {
786
public void testCycle6() throws JavaModelException {
787
	Hashtable options = JavaCore.getOptions();
787
	Hashtable options = JavaCore.getOptions();
788
	Hashtable newOptions = JavaCore.getOptions();
788
	Hashtable newOptions = JavaCore.getOptions();
789
	newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);
789
	newOptions.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.WARNING);
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (+1 lines)
Lines 6081-6086 Link Here
6081
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6081
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6082
		CompilationUnit compilationUnit = (CompilationUnit) node;
6082
		CompilationUnit compilationUnit = (CompilationUnit) node;
6083
		String expectedResult = 
6083
		String expectedResult = 
6084
			"The hierarchy of the type X is inconsistent\n" + 
6084
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6085
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6085
		assertProblemsSize(compilationUnit, 1, expectedResult);
6086
		assertProblemsSize(compilationUnit, 1, expectedResult);
6086
		compilationUnit.accept(new ASTVisitor() {
6087
		compilationUnit.accept(new ASTVisitor() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-19 / +39 lines)
Lines 30-50 Link Here
30
null is NOT a valid value for a non-public field... it just means the field is not initialized.
30
null is NOT a valid value for a non-public field... it just means the field is not initialized.
31
*/
31
*/
32
32
33
public final class BinaryTypeBinding extends ReferenceBinding {
33
public class BinaryTypeBinding extends ReferenceBinding {
34
34
35
	// all of these fields are ONLY guaranteed to be initialized if accessed using their public accessor method
35
	// all of these fields are ONLY guaranteed to be initialized if accessed using their public accessor method
36
	private ReferenceBinding superclass;
36
	protected ReferenceBinding superclass;
37
	private ReferenceBinding enclosingType;
37
	protected ReferenceBinding enclosingType;
38
	private ReferenceBinding[] superInterfaces;
38
	protected ReferenceBinding[] superInterfaces;
39
	private FieldBinding[] fields;
39
	protected FieldBinding[] fields;
40
	private MethodBinding[] methods;
40
	protected MethodBinding[] methods;
41
	private ReferenceBinding[] memberTypes;
41
	protected ReferenceBinding[] memberTypes;
42
	protected TypeVariableBinding[] typeVariables;
42
	protected TypeVariableBinding[] typeVariables;
43
43
44
	// For the link with the principle structure
44
	// For the link with the principle structure
45
	private LookupEnvironment environment;
45
	protected LookupEnvironment environment;
46
46
47
	private SimpleLookupTable storedAnnotations = null; // keys are this ReferenceBinding & its fields and methods, value is an AnnotationHolder
47
	protected SimpleLookupTable storedAnnotations = null; // keys are this ReferenceBinding & its fields and methods, value is an AnnotationHolder
48
48
49
static Object convertMemberValue(Object binaryValue, LookupEnvironment env) {
49
static Object convertMemberValue(Object binaryValue, LookupEnvironment env) {
50
	if (binaryValue == null) return null;
50
	if (binaryValue == null) return null;
Lines 133-138 Link Here
133
	return type;
133
	return type;
134
}
134
}
135
135
136
/**
137
 * Default empty constructor for subclasses only.
138
 */
139
protected BinaryTypeBinding() {
140
	// only for subclasses
141
}
142
143
/**
144
 * Standard constructor for creating binary type bindings from binary models (classfiles)
145
 * @param packageBinding
146
 * @param binaryType
147
 * @param environment
148
 */
136
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
149
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
137
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
150
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
138
	computeId();
151
	computeId();
Lines 252-258 Link Here
252
		if (superclassName != null) {
265
		if (superclassName != null) {
253
			// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested)
266
			// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested)
254
			this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false);
267
			this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false);
255
			this.tagBits |= 	TagBits.HasUnresolvedSuperclass;
268
			this.tagBits |= TagBits.HasUnresolvedSuperclass;
256
		}
269
		}
257
270
258
		this.superInterfaces = Binding.NO_SUPERINTERFACES;
271
		this.superInterfaces = Binding.NO_SUPERINTERFACES;
Lines 264-270 Link Here
264
				for (int i = 0; i < size; i++)
277
				for (int i = 0; i < size; i++)
265
					// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested)
278
					// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested)
266
					this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false);
279
					this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false);
267
				this.tagBits |= 	TagBits.HasUnresolvedSuperinterfaces;
280
				this.tagBits |= TagBits.HasUnresolvedSuperinterfaces;
268
			}
281
			}
269
		}
282
		}
270
	} else {
283
	} else {
Lines 281-287 Link Here
281
294
282
		// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested)
295
		// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested)
283
		this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this);
296
		this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this);
284
		this.tagBits |= 	TagBits.HasUnresolvedSuperclass;
297
		this.tagBits |= TagBits.HasUnresolvedSuperclass;
285
298
286
		this.superInterfaces = Binding.NO_SUPERINTERFACES;
299
		this.superInterfaces = Binding.NO_SUPERINTERFACES;
287
		if (!wrapper.atEnd()) {
300
		if (!wrapper.atEnd()) {
Lines 292-298 Link Here
292
			} while (!wrapper.atEnd());
305
			} while (!wrapper.atEnd());
293
			this.superInterfaces = new ReferenceBinding[types.size()];
306
			this.superInterfaces = new ReferenceBinding[types.size()];
294
			types.toArray(this.superInterfaces);
307
			types.toArray(this.superInterfaces);
295
			this.tagBits |= 	TagBits.HasUnresolvedSuperinterfaces;
308
			this.tagBits |= TagBits.HasUnresolvedSuperinterfaces;
296
		}
309
		}
297
	}
310
	}
298
311
Lines 893-900 Link Here
893
	}
906
	}
894
	return this.storedAnnotations;
907
	return this.storedAnnotations;
895
}
908
}
909
896
/* Answer the receiver's superclass... null if the receiver is Object or an interface.
910
/* Answer the receiver's superclass... null if the receiver is Object or an interface.
897
*
898
* NOTE: superclass of a binary type is resolved when needed
911
* NOTE: superclass of a binary type is resolved when needed
899
*/
912
*/
900
public ReferenceBinding superclass() {
913
public ReferenceBinding superclass() {
Lines 902-918 Link Here
902
		return this.superclass;
915
		return this.superclass;
903
916
904
	// finish resolving the type
917
	// finish resolving the type
905
	this.superclass = resolveType(this.superclass, this.environment, true);
918
	ReferenceBinding superType = resolveType(this.superclass, this.environment, true);
906
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
919
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
907
	return this.superclass;
920
	if (superType.problemId() == ProblemReasons.NotFound) {
921
		this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
922
	}
923
	return this.superclass = superType;
908
}
924
}
909
// NOTE: superInterfaces of binary types are resolved when needed
925
// NOTE: superInterfaces of binary types are resolved when needed
910
public ReferenceBinding[] superInterfaces() {
926
public ReferenceBinding[] superInterfaces() {
911
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
927
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
912
		return this.superInterfaces;
928
		return this.superInterfaces;
913
929
	for (int i = this.superInterfaces.length; --i >= 0;) {
914
	for (int i = this.superInterfaces.length; --i >= 0;)
930
		ReferenceBinding superType = resolveType(this.superInterfaces[i], this.environment, true);
915
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
931
		if (superType.problemId() == ProblemReasons.NotFound) {
932
			this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
933
		}
934
		this.superInterfaces[i] = superType;
935
	}
916
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
936
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
917
	return this.superInterfaces;
937
	return this.superInterfaces;
918
}
938
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-5 / +41 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 typeReferenceBeingResolved = null; // only set when resolving certain type references, to help locating problems
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 172-177 Link Here
172
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
174
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
173
	return null; // the type already exists & can be retrieved from the cache
175
	return null; // the type already exists & can be retrieved from the cache
174
}
176
}
177
178
public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName) {
179
	PackageBinding packageBinding = getPackage0(compoundName[0]);
180
	if (packageBinding == null || packageBinding == TheNotFoundPackage) {
181
		packageBinding = new PackageBinding(compoundName[0], this);
182
		knownPackages.put(compoundName[0], packageBinding);
183
	}
184
	for (int i = 1, packageLength = compoundName.length - 1; i < packageLength; i++) {
185
		PackageBinding subPackageBinding = packageBinding.getPackage0(compoundName[i]);
186
		if (subPackageBinding == null || subPackageBinding == TheNotFoundPackage) {
187
			char[][] subName = CharOperation.subarray(compoundName, 0, i + 1);
188
			subPackageBinding = new PackageBinding(subName, packageBinding, this);
189
			packageBinding.addPackage(subPackageBinding);
190
			packageBinding = subPackageBinding;
191
		}
192
	}
193
	// create a proxy for the missing BinaryType
194
	MissingBinaryTypeBinding type = new MissingBinaryTypeBinding(packageBinding, compoundName, this);
195
	if (type.id != TypeIds.T_JavaLangObject) {
196
		// make Object be its superclass - it could in turn be missing as well
197
		ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT);
198
		if (objectType == null) {
199
			objectType = cacheMissingBinaryType(TypeConstants.JAVA_LANG_OBJECT);	// create a proxy for the missing Object type		
200
		}
201
		type.setMissingSuperclass(objectType);
202
	}
203
	packageBinding.addType(type);
204
	return type;	
205
}
175
/*
206
/*
176
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
207
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
177
* 2. Create the field bindings
208
* 2. Create the field bindings
Lines 858-865 Link Here
858
	ReferenceBinding type = getType(compoundName);
889
	ReferenceBinding type = getType(compoundName);
859
	if (type != null) return type;
890
	if (type != null) return type;
860
891
861
	problemReporter.isClassPathCorrect(compoundName, scope == null ? null : scope.referenceCompilationUnit());
892
	ClassScope classScope = scope == null ? null : scope.enclosingClassScope();
862
	return null; // will not get here since the above error aborts the compilation
893
	problemReporter.isClassPathCorrect(
894
			compoundName, 
895
			scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit(), 
896
			classScope == null ? this.typeReferenceBeingResolved : classScope.superTypeReference);
897
	return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
863
}
898
}
864
/* Answer the top level package named name.
899
/* Answer the top level package named name.
865
* Ask the oracle for the package if its not in the cache.
900
* Ask the oracle for the package if its not in the cache.
Lines 956-969 Link Here
956
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
991
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
957
		packageBinding.addType(binding);
992
		packageBinding.addType(binding);
958
	} else if (binding == TheNotFoundType) {
993
	} else if (binding == TheNotFoundType) {
959
		problemReporter.isClassPathCorrect(compoundName, null);
994
		problemReporter.isClassPathCorrect(compoundName, this.unitBeingCompleted, this.typeReferenceBeingResolved);
960
		return null; // will not get here since the above error aborts the compilation
995
		return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
961
	} else if (!isParameterized) {
996
	} else if (!isParameterized) {
962
	    // check raw type, only for resolved types
997
	    // check raw type, only for resolved types
963
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
998
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
964
	}
999
	}
965
	return binding;
1000
	return binding;
966
}
1001
}
1002
967
/* Answer the type corresponding to the name from the binary file.
1003
/* Answer the type corresponding to the name from the binary file.
968
* Does not ask the oracle for the type if its not found in the cache... instead an
1004
* Does not ask the oracle for the type if its not found in the cache... instead an
969
* unresolved type is returned which must be resolved before used.
1005
* unresolved type is returned which must be resolved before used.
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-2 / +5 lines)
Lines 551-559 Link Here
551
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
551
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
552
552
553
	// abort if java.lang cannot be found...
553
	// abort if java.lang cannot be found...
554
	if (importBinding == null || !importBinding.isValidBinding())
554
	if (importBinding == null || !importBinding.isValidBinding()) {
555
		problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
555
		problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit(), null);
556
		BinaryTypeBinding missingObject = environment.cacheMissingBinaryType(JAVA_LANG_OBJECT);	// create a proxy for the missing BinaryType
557
		importBinding = missingObject.fPackage;
556
558
559
	}
557
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
560
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
558
}
561
}
559
// NOT Public API
562
// 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.typeReferenceBeingResolved);
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 (-2 / +6 lines)
Lines 1099-1117 Link Here
1099
	}
1099
	}
1100
1100
1101
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1101
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1102
		LookupEnvironment environment = environment();
1102
		try {
1103
		try {
1103
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1104
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1104
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1105
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1105
			this.superTypeReference = typeReference;
1106
			this.superTypeReference = typeReference;
1107
			environment.typeReferenceBeingResolved = typeReference;
1106
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1108
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1107
			this.superTypeReference = null;
1108
			return superType;
1109
			return superType;
1109
		} catch (AbortCompilation e) {
1110
		} catch (AbortCompilation e) {
1110
			SourceTypeBinding sourceType = this.referenceContext.binding;
1111
			SourceTypeBinding sourceType = this.referenceContext.binding;
1111
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1112
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1112
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1113
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1113
			throw e;
1114
			throw e;
1114
		}			
1115
		} finally {
1116
			environment.typeReferenceBeingResolved = null;
1117
			this.superTypeReference = null;
1118
		}
1115
	}
1119
	}
1116
1120
1117
	/* Answer the problem reporter to use for raising new problems.
1121
	/* Answer the problem reporter to use for raising new problems.
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-4 / +3 lines)
Lines 3405-3420 Link Here
3405
		argument.type.sourceStart,
3405
		argument.type.sourceStart,
3406
		argument.sourceEnd);
3406
		argument.sourceEnd);
3407
}
3407
}
3408
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3408
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, ASTNode location) {
3409
	this.referenceContext = compUnitDecl;
3409
	this.referenceContext = compUnitDecl;
3410
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3410
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3411
	this.handle(
3411
	this.handle(
3412
		IProblem.IsClassPathCorrect,
3412
		IProblem.IsClassPathCorrect,
3413
		arguments, 
3413
		arguments, 
3414
		arguments,
3414
		arguments,
3415
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3415
		location == null ? 0 : location.sourceStart,
3416
		0,
3416
		location == null ? 0 : location.sourceEnd);
3417
		0);
3418
}
3417
}
3419
private boolean isIdentifier(int token) {
3418
private boolean isIdentifier(int token) {
3420
	return token == TerminalTokens.TokenNameIdentifier;
3419
	return token == TerminalTokens.TokenNameIdentifier;
(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (-21 / +27 lines)
Lines 166-195 Link Here
166
	
166
	
167
	if (superBinding != null) {
167
	if (superBinding != null) {
168
		superBinding = (ReferenceBinding) superBinding.erasure();
168
		superBinding = (ReferenceBinding) superBinding.erasure();
169
		if (superBinding.id == TypeIds.T_JavaLangObject && typeBinding.isHierarchyInconsistent()) {
169
		if (typeBinding.isHierarchyInconsistent()) {
170
			char[] superclassName;
170
			if (superBinding.problemId() == ProblemReasons.NotFound) {
171
			char separator;
171
				this.hasMissingSuperClass = true;
172
			if (type instanceof IBinaryType) {
172
				this.builder.hierarchy.missingTypes.add(new String(superBinding.sourceName)); // note: this could be Map$Entry
173
				superclassName = ((IBinaryType)type).getSuperclassName();
174
				separator = '/';
175
			} else if (type instanceof ISourceType) {
176
				superclassName = ((ISourceType)type).getSuperclassName();
177
				separator = '.';
178
			} else if (type instanceof HierarchyType) {
179
				superclassName = ((HierarchyType)type).superclassName;
180
				separator = '.';
181
			} else {
182
				return null;
173
				return null;
183
			}
174
			} else if ((superBinding.id == TypeIds.T_JavaLangObject)) {
184
			
175
				char[] superclassName;
185
			if (superclassName != null) { // check whether subclass of Object due to broken hierarchy (as opposed to explicitly extending it)
176
				char separator;
186
				int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
177
				if (type instanceof IBinaryType) {
187
				char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
178
					superclassName = ((IBinaryType)type).getSuperclassName();
188
				if (!CharOperation.equals(simpleName, TypeConstants.OBJECT)) {
179
					separator = '/';
189
					this.hasMissingSuperClass = true;
180
				} else if (type instanceof ISourceType) {
190
					this.builder.hierarchy.missingTypes.add(new String(simpleName));
181
					superclassName = ((ISourceType)type).getSuperclassName();
182
					separator = '.';
183
				} else if (type instanceof HierarchyType) {
184
					superclassName = ((HierarchyType)type).superclassName;
185
					separator = '.';
186
				} else {
191
					return null;
187
					return null;
192
				}
188
				}
189
				
190
				if (superclassName != null) { // check whether subclass of Object due to broken hierarchy (as opposed to explicitly extending it)
191
					int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
192
					char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
193
					if (!CharOperation.equals(simpleName, TypeConstants.OBJECT)) {
194
						this.hasMissingSuperClass = true;
195
						this.builder.hierarchy.missingTypes.add(new String(simpleName));
196
						return null;
197
					}
198
				}
193
			}
199
			}
194
		}
200
		}
195
		for (int t = this.typeIndex; t >= 0; t--) {
201
		for (int t = this.typeIndex; t >= 0; t--) {
(-)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 546-569 Link Here
546
 */
548
 */
547
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
549
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
548
	if (sourceFile == null || problems == null || problems.length == 0) return;
550
	if (sourceFile == null || problems == null || problems.length == 0) return;
551
	 // once a classpath error is found, ignore all other problems for this project so the user can see the main error
552
	// but still try to compile as many source files as possible to help the case when the base libraries are in source
553
	if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
549
554
550
	String missingClassFile = null;
551
	IResource resource = sourceFile.resource;
555
	IResource resource = sourceFile.resource;
552
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
556
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
553
	for (int i = 0, l = problems.length; i < l; i++) {
557
	for (int i = 0, l = problems.length; i < l; i++) {
554
		CategorizedProblem problem = problems[i];
558
		CategorizedProblem problem = problems[i];
555
		int id = problem.getID();
559
		int id = problem.getID();
560
		
561
		// handle missing classfile situation
556
		if (id == IProblem.IsClassPathCorrect) {
562
		if (id == IProblem.IsClassPathCorrect) {
557
			JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
563
			String missingClassfileName = problem.getArguments()[0];
558
			String[] args = problem.getArguments();
564
			if (JavaBuilder.DEBUG)
559
			missingClassFile = args[0];
565
				System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
566
			boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
567
			// insert extra classpath problem, and make it the only problem for this project (optional)
568
			if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
569
				JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
570
				this.keepStoringProblemMarkers = false;
571
			}
572
			IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
573
			marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); 
574
			marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
575
			marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
576
			// if not keeping more markers, still fall through rest of the problem reporting, so that offending IsClassPathCorrect 
577
			// problem gets recorded since it may help locating the offending reference
560
		}
578
		}
561
		
579
562
		String markerType = problem.getMarkerType();
580
		String markerType = problem.getMarkerType();
563
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
581
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) || managedMarkerTypes.contains(markerType)) {
564
				|| managedMarkerTypes.contains(markerType)) {			
565
			IMarker marker = resource.createMarker(markerType);
582
			IMarker marker = resource.createMarker(markerType);
566
			
583
567
			// standard attributes
584
			// standard attributes
568
			marker.setAttributes(
585
			marker.setAttributes(
569
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
586
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
Lines 584-592 Link Here
584
			if (extraLength > 0) {
601
			if (extraLength > 0) {
585
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
602
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
586
			}
603
			}
604
			
605
			if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
587
		}
606
		}
588
		if (missingClassFile != null)
589
			throw new MissingClassFileException(missingClassFile);
590
	}
607
	}
591
}
608
}
592
609
(-)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)
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java (+57 lines)
Added 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.compiler.lookup;
12
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
16
public class MissingBinaryTypeBinding extends BinaryTypeBinding {
17
18
/**
19
 * Special constructor for constructing proxies of missing binary types (114349)
20
 * @param packageBinding
21
 * @param compoundName
22
 * @param environment
23
 */
24
public MissingBinaryTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) {
25
	this.compoundName = compoundName;
26
	computeId();
27
	this.tagBits |= TagBits.IsBinaryBinding|TagBits.HierarchyHasProblems;
28
	this.environment = environment;
29
	this.fPackage = packageBinding;
30
	this.fileName = CharOperation.concatWith(compoundName, '/');
31
	this.sourceName = compoundName[compoundName.length - 1]; // [java][util][Map$Entry]
32
	this.modifiers = ClassFileConstants.AccPublic;
33
	this.superclass = null; // will be fixed up using #setMissingSuperclass(...)
34
	this.superInterfaces = Binding.NO_SUPERINTERFACES;
35
	this.typeVariables = Binding.NO_TYPE_VARIABLES;
36
	this.memberTypes = Binding.NO_MEMBER_TYPES;
37
	this.fields = Binding.NO_FIELDS;
38
	this.methods = Binding.NO_METHODS;
39
}	
40
	
41
/**
42
 * Missing binary type will answer <code>false</code> to #isValidBinding()
43
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#problemId()
44
 */
45
public int problemId() {
46
	return ProblemReasons.NotFound;
47
}
48
49
/**
50
 * Only used to fixup the superclass hierarchy of proxy binary types
51
 * @param missingSuperclass
52
 * @see LookupEnvironment#cacheMissingBinaryType(char[][])
53
 */
54
void setMissingSuperclass(ReferenceBinding missingSuperclass) {
55
	this.superclass = missingSuperclass;
56
}	
57
}

Return to bug 114349