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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (-3 / +3 lines)
Lines 1877-1884 Link Here
1877
			"/Reconciler/src/p1/X01.java", 
1877
			"/Reconciler/src/p1/X01.java", 
1878
			"package p1;\n" +
1878
			"package p1;\n" +
1879
			"public abstract class X01 {\n" +
1879
			"public abstract class X01 {\n" +
1880
			"	public abstract void bar();	\n"+
1880
			"  public abstract void bar();	\n"+
1881
			"  public abstract void foo(Zork z); \n"+
1881
			"  public void foo(Zork z); \n"+ // problem: Zork undefined
1882
			"}"
1882
			"}"
1883
		);
1883
		);
1884
		String contents = 
1884
		String contents = 
Lines 3482-3488 Link Here
3482
}
3482
}
3483
3483
3484
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=107931
3484
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=107931
3485
public void _test1001() throws CoreException, InterruptedException, IOException {
3485
public void test1001() throws CoreException, InterruptedException, IOException {
3486
	try {
3486
	try {
3487
		// Resources creation
3487
		// Resources creation
3488
		String sources[] = new String[3];
3488
		String sources[] = new String[3];
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (+1 lines)
Lines 6087-6092 Link Here
6087
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6087
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6088
		CompilationUnit compilationUnit = (CompilationUnit) node;
6088
		CompilationUnit compilationUnit = (CompilationUnit) node;
6089
		String expectedResult = 
6089
		String expectedResult = 
6090
			"The hierarchy of the type X is inconsistent\n" + 
6090
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6091
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6091
		assertProblemsSize(compilationUnit, 1, expectedResult);
6092
		assertProblemsSize(compilationUnit, 1, expectedResult);
6092
		compilationUnit.accept(new ASTVisitor() {
6093
		compilationUnit.accept(new ASTVisitor() {
(-)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);
(-)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 897-904 Link Here
897
	}
910
	}
898
	return this.storedAnnotations;
911
	return this.storedAnnotations;
899
}
912
}
913
900
/* Answer the receiver's superclass... null if the receiver is Object or an interface.
914
/* Answer the receiver's superclass... null if the receiver is Object or an interface.
901
*
902
* NOTE: superclass of a binary type is resolved when needed
915
* NOTE: superclass of a binary type is resolved when needed
903
*/
916
*/
904
public ReferenceBinding superclass() {
917
public ReferenceBinding superclass() {
Lines 906-922 Link Here
906
		return this.superclass;
919
		return this.superclass;
907
920
908
	// finish resolving the type
921
	// finish resolving the type
909
	this.superclass = resolveType(this.superclass, this.environment, true);
922
	ReferenceBinding superType = resolveType(this.superclass, this.environment, true);
910
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
923
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
911
	return this.superclass;
924
	if (superType.problemId() == ProblemReasons.NotFound) {
925
		this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
926
	}
927
	return this.superclass = superType;
912
}
928
}
913
// NOTE: superInterfaces of binary types are resolved when needed
929
// NOTE: superInterfaces of binary types are resolved when needed
914
public ReferenceBinding[] superInterfaces() {
930
public ReferenceBinding[] superInterfaces() {
915
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
931
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
916
		return this.superInterfaces;
932
		return this.superInterfaces;
917
933
	for (int i = this.superInterfaces.length; --i >= 0;) {
918
	for (int i = this.superInterfaces.length; --i >= 0;)
934
		ReferenceBinding superType = resolveType(this.superInterfaces[i], this.environment, true);
919
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
935
		if (superType.problemId() == ProblemReasons.NotFound) {
936
			this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
937
		}
938
		this.superInterfaces[i] = superType;
939
	}
920
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
940
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
921
	return this.superInterfaces;
941
	return this.superInterfaces;
922
}
942
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-13 / +7 lines)
Lines 1356-1361 Link Here
1356
			Argument arg = arguments[i];
1356
			Argument arg = arguments[i];
1357
			TypeBinding parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
1357
			TypeBinding parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/);
1358
			if (parameterType == null) {
1358
			if (parameterType == null) {
1359
				parameterType = arg.type.resolvedType; // must be a problem type
1359
				foundArgProblem = true;
1360
				foundArgProblem = true;
1360
			} else if (parameterType == TypeBinding.VOID) {
1361
			} else if (parameterType == TypeBinding.VOID) {
1361
				methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg);
1362
				methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg);
Lines 1367-1374 Link Here
1367
				TypeBinding leafType = parameterType.leafComponentType();
1368
				TypeBinding leafType = parameterType.leafComponentType();
1368
			    if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0)
1369
			    if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0)
1369
					method.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
1370
					method.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
1370
				method.parameters[i] = parameterType;
1371
			}
1371
			}
1372
			method.parameters[i] = parameterType;
1372
		}
1373
		}
1373
	}
1374
	}
1374
1375
Lines 1396-1414 Link Here
1396
			}
1397
			}
1397
		}
1398
		}
1398
	}
1399
	}
1399
	if (foundArgProblem) {
1400
	if (foundArgProblem || foundReturnTypeProblem) {
1400
		methodDecl.binding = null;
1401
		return method; 
1401
		method.parameters = Binding.NO_PARAMETERS; // see 107004
1402
		// but its still unresolved with either a null return type or
1402
		// nullify type parameter bindings as well as they have a backpointer to the method binding
1403
		// problem parameters & is still connected to its method declaration
1403
		// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81134)
1404
		// TODO may want to explicitly mark it as a problem binding
1404
		if (typeParameters != null)
1405
			for (int i = 0, length = typeParameters.length; i < length; i++)
1406
				typeParameters[i].binding = null;
1407
		return null;
1408
	}
1405
	}
1409
	if (foundReturnTypeProblem)
1410
		return method; // but its still unresolved with a null return type & is still connected to its method declaration
1411
1412
	method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
1406
	method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
1413
	return method;
1407
	return method;
1414
}
1408
}
(-)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 860-867 Link Here
860
	ReferenceBinding type = getType(compoundName);
891
	ReferenceBinding type = getType(compoundName);
861
	if (type != null) return type;
892
	if (type != null) return type;
862
893
863
	problemReporter.isClassPathCorrect(compoundName, scope == null ? null : scope.referenceCompilationUnit());
894
	ClassScope classScope = scope == null ? null : scope.enclosingClassScope();
864
	return null; // will not get here since the above error aborts the compilation
895
	problemReporter.isClassPathCorrect(
896
			compoundName, 
897
			scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit(), 
898
			classScope == null ? this.typeReferenceBeingResolved : classScope.superTypeReference);
899
	return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
865
}
900
}
866
/* Answer the top level package named name.
901
/* Answer the top level package named name.
867
* Ask the oracle for the package if its not in the cache.
902
* Ask the oracle for the package if its not in the cache.
Lines 958-971 Link Here
958
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
993
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
959
		packageBinding.addType(binding);
994
		packageBinding.addType(binding);
960
	} else if (binding == TheNotFoundType) {
995
	} else if (binding == TheNotFoundType) {
961
		problemReporter.isClassPathCorrect(compoundName, null);
996
		problemReporter.isClassPathCorrect(compoundName, this.unitBeingCompleted, this.typeReferenceBeingResolved);
962
		return null; // will not get here since the above error aborts the compilation
997
		return cacheMissingBinaryType(compoundName);	// create a proxy for the missing BinaryType
963
	} else if (!isParameterized) {
998
	} else if (!isParameterized) {
964
	    // check raw type, only for resolved types
999
	    // check raw type, only for resolved types
965
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
1000
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
966
	}
1001
	}
967
	return binding;
1002
	return binding;
968
}
1003
}
1004
969
/* Answer the type corresponding to the name from the binary file.
1005
/* Answer the type corresponding to the name from the binary file.
970
* Does not ask the oracle for the type if its not found in the cache... instead an
1006
* Does not ask the oracle for the type if its not found in the cache... instead an
971
* unresolved type is returned which must be resolved before used.
1007
* unresolved type is returned which must be resolved before used.
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java (+1 lines)
Lines 18-23 Link Here
18
18
19
public ProblemReferenceBinding(char[][] compoundName, ReferenceBinding closestMatch, int problemReason) {
19
public ProblemReferenceBinding(char[][] compoundName, ReferenceBinding closestMatch, int problemReason) {
20
	this.compoundName = compoundName;
20
	this.compoundName = compoundName;
21
	this.sourceName = compoundName[compoundName.length - 1]; // reasonable guess
21
	this.closestMatch = closestMatch;
22
	this.closestMatch = closestMatch;
22
	this.problemReason = problemReason;
23
	this.problemReason = problemReason;
23
}
24
}
(-)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 3442-3457 Link Here
3442
		argument.type.sourceStart,
3442
		argument.type.sourceStart,
3443
		argument.sourceEnd);
3443
		argument.sourceEnd);
3444
}
3444
}
3445
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3445
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, ASTNode location) {
3446
	this.referenceContext = compUnitDecl;
3446
	this.referenceContext = compUnitDecl;
3447
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3447
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3448
	this.handle(
3448
	this.handle(
3449
		IProblem.IsClassPathCorrect,
3449
		IProblem.IsClassPathCorrect,
3450
		arguments, 
3450
		arguments, 
3451
		arguments,
3451
		arguments,
3452
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3452
		location == null ? 0 : location.sourceStart,
3453
		0,
3453
		location == null ? 0 : location.sourceEnd);
3454
		0);
3455
}
3454
}
3456
private boolean isIdentifier(int token) {
3455
private boolean isIdentifier(int token) {
3457
	return token == TerminalTokens.TokenNameIdentifier;
3456
	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/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)
(-)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
(-)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 107931