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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java (-11 / +10 lines)
Lines 212-226 Link Here
212
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
212
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
213
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
213
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
214
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
214
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
215
	} catch (MissingClassFileException e) {
216
		// do not log this exception since its thrown to handle aborted compiles because of missing class files
217
		if (DEBUG)
218
			System.out.println(Messages.bind(Messages.build_incompleteClassPath, e.missingClassFile)); 
219
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
220
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, e.missingClassFile)); 
221
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
222
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
223
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
224
	} catch (MissingSourceFileException e) {
215
	} catch (MissingSourceFileException e) {
225
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
216
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
226
		if (DEBUG)
217
		if (DEBUG)
Lines 291-297 Link Here
291
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
282
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
292
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
283
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
293
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
284
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
294
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);		
285
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
295
	} finally {
286
	} finally {
296
		notifier.done();
287
		notifier.done();
297
		cleanup();
288
		cleanup();
Lines 438-443 Link Here
438
	return result;
429
	return result;
439
}
430
}
440
431
432
boolean hasBuildpathErrors() throws CoreException {
433
	IMarker[] markers = this.currentProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
434
	for (int i = 0, l = markers.length; i < l; i++)
435
		if (markers[i].getAttribute(IJavaModelMarker.CATEGORY_ID, -1) == CategorizedProblem.CAT_BUILDPATH)
436
			return true;
437
	return false;
438
}
439
441
private boolean hasClasspathChanged() {
440
private boolean hasClasspathChanged() {
442
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
441
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
443
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
442
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
Lines 591-597 Link Here
591
private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
590
private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
592
	IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
591
	IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
593
	for (int i = 0, l = markers.length; i < l; i++)
592
	for (int i = 0, l = markers.length; i < l; i++)
594
		if (((Integer) markers[i].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR)
593
		if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR)
595
			return true;
594
			return true;
596
	return false;
595
	return false;
597
}
596
}
(-)model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java (-22 / +32 lines)
Lines 13-19 Link Here
13
import org.eclipse.core.resources.*;
13
import org.eclipse.core.resources.*;
14
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.*;
15
15
16
import org.eclipse.jdt.core.JavaCore;
16
import org.eclipse.jdt.core.*;
17
import org.eclipse.jdt.core.compiler.*;
17
import org.eclipse.jdt.core.compiler.*;
18
import org.eclipse.jdt.internal.compiler.*;
18
import org.eclipse.jdt.internal.compiler.*;
19
import org.eclipse.jdt.internal.compiler.classfmt.*;
19
import org.eclipse.jdt.internal.compiler.classfmt.*;
Lines 77-104 Link Here
77
	try {
77
	try {
78
		resetCollections();
78
		resetCollections();
79
79
80
		notifier.subTask(Messages.build_analyzingDeltas); 
80
		notifier.subTask(Messages.build_analyzingDeltas);
81
		IResourceDelta sourceDelta = (IResourceDelta) deltas.get(javaBuilder.currentProject);
81
		if (javaBuilder.hasBuildpathErrors()) {
82
		if (sourceDelta != null)
82
			// if a mssing class file was detected in the last build, a build state was saved since its no longer fatal
83
			if (!findSourceFiles(sourceDelta)) return false;
83
			// but we need to rebuild every source file since problems were not recorded
84
		notifier.updateProgressDelta(0.10f);
84
			// AND to avoid the infinite build scenario if this project is involved in a cycle, see bug 160550
85
85
			// we need to avoid unnecessary deltas caused by doing a full build in this case
86
		Object[] keyTable = deltas.keyTable;
86
			javaBuilder.currentProject.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
87
		Object[] valueTable = deltas.valueTable;
87
			addAllSourceFiles(sourceFiles);
88
		for (int i = 0, l = valueTable.length; i < l; i++) {
88
			notifier.updateProgressDelta(0.25f);
89
			IResourceDelta delta = (IResourceDelta) valueTable[i];
89
		} else {
90
			if (delta != null) {
90
			IResourceDelta sourceDelta = (IResourceDelta) deltas.get(javaBuilder.currentProject);
91
				IProject p = (IProject) keyTable[i];
91
			if (sourceDelta != null)
92
				ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) javaBuilder.binaryLocationsPerProject.get(p);
92
				if (!findSourceFiles(sourceDelta)) return false;
93
				if (classFoldersAndJars != null)
93
			notifier.updateProgressDelta(0.10f);
94
					if (!findAffectedSourceFiles(delta, classFoldersAndJars, p)) return false;
94
95
			Object[] keyTable = deltas.keyTable;
96
			Object[] valueTable = deltas.valueTable;
97
			for (int i = 0, l = valueTable.length; i < l; i++) {
98
				IResourceDelta delta = (IResourceDelta) valueTable[i];
99
				if (delta != null) {
100
					IProject p = (IProject) keyTable[i];
101
					ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) javaBuilder.binaryLocationsPerProject.get(p);
102
					if (classFoldersAndJars != null)
103
						if (!findAffectedSourceFiles(delta, classFoldersAndJars, p)) return false;
104
				}
95
			}
105
			}
96
		}
106
			notifier.updateProgressDelta(0.10f);
97
		notifier.updateProgressDelta(0.10f);
98
107
99
		notifier.subTask(Messages.build_analyzingSources); 
108
			notifier.subTask(Messages.build_analyzingSources); 
100
		addAffectedSourceFiles();
109
			addAffectedSourceFiles();
101
		notifier.updateProgressDelta(0.05f);
110
			notifier.updateProgressDelta(0.05f);
111
		}
102
112
103
		this.compileLoop = 0;
113
		this.compileLoop = 0;
104
		float increment = 0.40f;
114
		float increment = 0.40f;
Lines 590-596 Link Here
590
					IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
600
					IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
591
					if (newState.isKnownType(typePath.toString())) {
601
					if (newState.isKnownType(typePath.toString())) {
592
						if (JavaBuilder.DEBUG)
602
						if (JavaBuilder.DEBUG)
593
							System.out.println("MOST DO FULL BUILD. Found change to class file " + typePath); //$NON-NLS-1$
603
							System.out.println("MUST DO FULL BUILD. Found change to class file " + typePath); //$NON-NLS-1$
594
						return false;
604
						return false;
595
					}
605
					}
596
				}
606
				}
(-)model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java (-42 lines)
Lines 79-126 Link Here
79
		this.secondaryTypes.add(classFile.fileName());
79
		this.secondaryTypes.add(classFile.fileName());
80
}
80
}
81
81
82
protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {
83
	for (int i = 0, l = sourceLocations.length; i < l; i++) {
84
		final ClasspathMultiDirectory sourceLocation = sourceLocations[i];
85
		final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
86
		final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
87
		final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
88
		final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
89
		final IContainer outputFolder = sourceLocation.binaryFolder;
90
		final boolean isOutputFolder = sourceLocation.sourceFolder.equals(outputFolder);
91
		sourceLocation.sourceFolder.accept(
92
			new IResourceProxyVisitor() {
93
				public boolean visit(IResourceProxy proxy) throws CoreException {
94
					switch(proxy.getType()) {
95
						case IResource.FILE :
96
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
97
								IResource resource = proxy.requestResource();
98
								if (exclusionPatterns != null || inclusionPatterns != null)
99
									if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
100
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
101
							}
102
							return false;
103
						case IResource.FOLDER :
104
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
105
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
106
							IPath folderPath = null;
107
							if (isAlsoProject)
108
								if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false;
109
							if (!isOutputFolder) {
110
								if (folderPath == null)
111
									folderPath = proxy.requestFullPath();
112
								createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
113
							}
114
					}
115
					return true;
116
				}
117
			},
118
			IResource.NONE
119
		);
120
		notifier.checkCancel();
121
	}
122
}
123
124
protected void cleanOutputFolders(boolean copyBack) throws CoreException {
82
protected void cleanOutputFolders(boolean copyBack) throws CoreException {
125
	boolean deleteAll = JavaCore.CLEAN.equals(
83
	boolean deleteAll = JavaCore.CLEAN.equals(
126
		javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
84
		javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
(-)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 (-9 / +70 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 85-90 Link Here
85
	this.nameEnvironment = javaBuilder.nameEnvironment;
86
	this.nameEnvironment = javaBuilder.nameEnvironment;
86
	this.sourceLocations = this.nameEnvironment.sourceLocations;
87
	this.sourceLocations = this.nameEnvironment.sourceLocations;
87
	this.notifier = javaBuilder.notifier;
88
	this.notifier = javaBuilder.notifier;
89
	this.keepStoringProblemMarkers = true; // may get disabled when missing classfiles are encountered
88
90
89
	if (buildStarting) {
91
	if (buildStarting) {
90
		this.newState = newState == null ? new State(javaBuilder) : newState;
92
		this.newState = newState == null ? new State(javaBuilder) : newState;
Lines 200-205 Link Here
200
	// noop
202
	// noop
201
}
203
}
202
204
205
protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {
206
	for (int i = 0, l = sourceLocations.length; i < l; i++) {
207
		final ClasspathMultiDirectory sourceLocation = sourceLocations[i];
208
		final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
209
		final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
210
		final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
211
		final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
212
		final IContainer outputFolder = sourceLocation.binaryFolder;
213
		final boolean isOutputFolder = sourceLocation.sourceFolder.equals(outputFolder);
214
		sourceLocation.sourceFolder.accept(
215
			new IResourceProxyVisitor() {
216
				public boolean visit(IResourceProxy proxy) throws CoreException {
217
					switch(proxy.getType()) {
218
						case IResource.FILE :
219
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
220
								IResource resource = proxy.requestResource();
221
								if (exclusionPatterns != null || inclusionPatterns != null)
222
									if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
223
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
224
							}
225
							return false;
226
						case IResource.FOLDER :
227
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
228
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
229
							IPath folderPath = null;
230
							if (isAlsoProject)
231
								if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false;
232
							if (!isOutputFolder) {
233
								if (folderPath == null)
234
									folderPath = proxy.requestFullPath();
235
								createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
236
							}
237
					}
238
					return true;
239
				}
240
			},
241
			IResource.NONE
242
		);
243
		notifier.checkCancel();
244
	}
245
}
246
203
protected void cleanUp() {
247
protected void cleanUp() {
204
	this.nameEnvironment.cleanup();
248
	this.nameEnvironment.cleanup();
205
249
Lines 550-574 Link Here
550
 */
594
 */
551
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
595
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
552
	if (sourceFile == null || problems == null || problems.length == 0) return;
596
	if (sourceFile == null || problems == null || problems.length == 0) return;
597
	 // once a classpath error is found, ignore all other problems for this project so the user can see the main error
598
	// but still try to compile as many source files as possible to help the case when the base libraries are in source
599
	if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
553
600
554
	String missingClassFile = null;
555
	IResource resource = sourceFile.resource;
601
	IResource resource = sourceFile.resource;
556
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
602
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
557
	for (int i = 0, l = problems.length; i < l; i++) {
603
	for (int i = 0, l = problems.length; i < l; i++) {
558
		CategorizedProblem problem = problems[i];
604
		CategorizedProblem problem = problems[i];
559
		int id = problem.getID();
605
		int id = problem.getID();
606
607
		// handle missing classfile situation
560
		if (id == IProblem.IsClassPathCorrect) {
608
		if (id == IProblem.IsClassPathCorrect) {
561
			JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
609
			String missingClassfileName = problem.getArguments()[0];
562
			String[] args = problem.getArguments();
610
			if (JavaBuilder.DEBUG)
563
			missingClassFile = args[0];
611
				System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
612
			boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
613
			// insert extra classpath problem, and make it the only problem for this project (optional)
614
			if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
615
				JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
616
				this.keepStoringProblemMarkers = false;
617
			}
618
			IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
619
			marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); 
620
			marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
621
			marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
622
			marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
623
			// even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
624
			// IsClassPathCorrect problem gets recorded since it may help locate the offending reference
564
		}
625
		}
565
		
626
566
		String markerType = problem.getMarkerType();
627
		String markerType = problem.getMarkerType();
567
		boolean managedProblem = false;
628
		boolean managedProblem = false;
568
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
629
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
569
				|| (managedProblem = managedMarkerTypes.contains(markerType))) {			
630
				|| (managedProblem = managedMarkerTypes.contains(markerType))) {
570
			IMarker marker = resource.createMarker(markerType);
631
			IMarker marker = resource.createMarker(markerType);
571
			
632
572
			// standard attributes
633
			// standard attributes
573
			marker.setAttributes(
634
			marker.setAttributes(
574
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
635
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
Lines 593-601 Link Here
593
			if (extraLength > 0) {
654
			if (extraLength > 0) {
594
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
655
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
595
			}
656
			}
657
658
			if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
596
		}
659
		}
597
		if (missingClassFile != null)
598
			throw new MissingClassFileException(missingClassFile);
599
	}
660
	}
600
}
661
}
601
662
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-3 / +12 lines)
Lines 957-967 Link Here
957
				problemReporter().hierarchyHasProblems(sourceType);
957
				problemReporter().hierarchyHasProblems(sourceType);
958
		}
958
		}
959
		connectMemberTypes();
959
		connectMemberTypes();
960
		LookupEnvironment env = environment();
960
		try {
961
		try {
962
			env.missingClassFileLocation = referenceContext;
961
			checkForInheritedMemberTypes(sourceType);
963
			checkForInheritedMemberTypes(sourceType);
962
		} catch (AbortCompilation e) {
964
		} catch (AbortCompilation e) {
963
			e.updateContext(referenceContext, referenceCompilationUnit().compilationResult);
965
			e.updateContext(referenceContext, referenceCompilationUnit().compilationResult);
964
			throw e;
966
			throw e;
967
		} finally {
968
			env.missingClassFileLocation = null;
965
		}
969
		}
966
	}
970
	}
967
	
971
	
Lines 1099-1117 Link Here
1099
	}
1103
	}
1100
1104
1101
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1105
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1106
		CompilationUnitScope unitScope = compilationUnitScope();
1107
		LookupEnvironment env = unitScope.environment;
1102
		try {
1108
		try {
1109
			env.missingClassFileLocation = typeReference;
1103
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1110
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1104
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1111
			unitScope.recordQualifiedReference(typeReference.getTypeName());
1105
			this.superTypeReference = typeReference;
1112
			this.superTypeReference = typeReference;
1106
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1113
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1107
			this.superTypeReference = null;
1108
			return superType;
1114
			return superType;
1109
		} catch (AbortCompilation e) {
1115
		} catch (AbortCompilation e) {
1110
			SourceTypeBinding sourceType = this.referenceContext.binding;
1116
			SourceTypeBinding sourceType = this.referenceContext.binding;
1111
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1117
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1112
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1118
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1113
			throw e;
1119
			throw e;
1114
		}			
1120
		} finally {
1121
			env.missingClassFileLocation = null;
1122
			this.superTypeReference = null;
1123
		}
1115
	}
1124
	}
1116
1125
1117
	/* Answer the problem reporter to use for raising new problems.
1126
	/* Answer the problem reporter to use for raising new problems.
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-8 / +23 lines)
Lines 1355-1362 Link Here
1355
	 *	Limitations: cannot request FIELD independently of LOCAL, or vice versa
1355
	 *	Limitations: cannot request FIELD independently of LOCAL, or vice versa
1356
	 */
1356
	 */
1357
	public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) {
1357
	public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) {
1358
1358
		CompilationUnitScope unitScope = compilationUnitScope();
1359
		LookupEnvironment env = unitScope.environment;
1359
		try {
1360
		try {
1361
			env.missingClassFileLocation = invocationSite;
1360
			Binding binding = null;
1362
			Binding binding = null;
1361
			FieldBinding problemField = null;
1363
			FieldBinding problemField = null;
1362
			if ((mask & Binding.VARIABLE) != 0) {
1364
			if ((mask & Binding.VARIABLE) != 0) {
Lines 1499-1505 Link Here
1499
1501
1500
				if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
1502
				if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
1501
					// at this point the scope is a compilation unit scope & need to check for imported static fields
1503
					// at this point the scope is a compilation unit scope & need to check for imported static fields
1502
					CompilationUnitScope unitScope = (CompilationUnitScope) scope;
1503
					ImportBinding[] imports = unitScope.imports;
1504
					ImportBinding[] imports = unitScope.imports;
1504
					if (imports != null) {
1505
					if (imports != null) {
1505
						// check single static imports
1506
						// check single static imports
Lines 1564-1572 Link Here
1564
					return binding;
1565
					return binding;
1565
				// answer the problem type binding if we are only looking for a type
1566
				// answer the problem type binding if we are only looking for a type
1566
			} else if ((mask & Binding.PACKAGE) != 0) {
1567
			} else if ((mask & Binding.PACKAGE) != 0) {
1567
				CompilationUnitScope unitScope = compilationUnitScope();
1568
				unitScope.recordSimpleReference(name);
1568
				unitScope.recordSimpleReference(name);
1569
				if ((binding = unitScope.environment.getTopLevelPackage(name)) != null)
1569
				if ((binding = env.getTopLevelPackage(name)) != null)
1570
					return binding;
1570
					return binding;
1571
			}
1571
			}
1572
			if (problemField != null) return problemField;
1572
			if (problemField != null) return problemField;
Lines 1576-1587 Link Here
1576
		} catch (AbortCompilation e) {
1576
		} catch (AbortCompilation e) {
1577
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1577
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1578
			throw e;
1578
			throw e;
1579
		} finally {
1580
			env.missingClassFileLocation = null;
1579
		}
1581
		}
1580
	}
1582
	}
1581
1583
1582
	public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1584
	public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1585
		CompilationUnitScope unitScope = compilationUnitScope();
1586
		LookupEnvironment env = unitScope.environment;
1583
		try {
1587
		try {
1584
			CompilationUnitScope unitScope = compilationUnitScope();
1588
			env.missingClassFileLocation = invocationSite;
1585
			unitScope.recordTypeReference(receiverType);
1589
			unitScope.recordTypeReference(receiverType);
1586
			unitScope.recordTypeReferences(argumentTypes);
1590
			unitScope.recordTypeReferences(argumentTypes);
1587
			MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
1591
			MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
Lines 1636-1641 Link Here
1636
		} catch (AbortCompilation e) {
1640
		} catch (AbortCompilation e) {
1637
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1641
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1638
			throw e;
1642
			throw e;
1643
		} finally {
1644
			env.missingClassFileLocation = null;
1639
		}
1645
		}
1640
	}
1646
	}
1641
1647
Lines 1680-1686 Link Here
1680
	}
1686
	}
1681
1687
1682
	public FieldBinding getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
1688
	public FieldBinding getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
1689
		LookupEnvironment env = environment();
1683
		try {
1690
		try {
1691
			env.missingClassFileLocation = invocationSite;
1684
			FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
1692
			FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
1685
			if (field != null) return field;
1693
			if (field != null) return field;
1686
	
1694
	
Lines 1691-1697 Link Here
1691
		} catch (AbortCompilation e) {
1699
		} catch (AbortCompilation e) {
1692
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1700
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1693
			throw e;
1701
			throw e;
1694
		}			
1702
		} finally {
1703
			env.missingClassFileLocation = null;
1704
		}
1695
	}
1705
	}
1696
	
1706
	
1697
	/* API
1707
	/* API
Lines 1981-1995 Link Here
1981
	}
1991
	}
1982
1992
1983
	public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1993
	public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1994
		CompilationUnitScope unitScope = compilationUnitScope();
1995
		LookupEnvironment env = unitScope.environment;
1984
		try {
1996
		try {
1997
			env.missingClassFileLocation = invocationSite;
1985
			switch (receiverType.kind()) {
1998
			switch (receiverType.kind()) {
1986
				case Binding.BASE_TYPE :
1999
				case Binding.BASE_TYPE :
1987
					return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
2000
					return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
1988
				case Binding.ARRAY_TYPE :
2001
				case Binding.ARRAY_TYPE :
1989
					compilationUnitScope().recordTypeReference(receiverType);
2002
					unitScope.recordTypeReference(receiverType);
1990
					return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
2003
					return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
1991
			}
2004
			}
1992
			compilationUnitScope().recordTypeReference(receiverType);
2005
			unitScope.recordTypeReference(receiverType);
1993
2006
1994
			ReferenceBinding currentType = (ReferenceBinding) receiverType;
2007
			ReferenceBinding currentType = (ReferenceBinding) receiverType;
1995
			if (!currentType.canBeSeenBy(this))
2008
			if (!currentType.canBeSeenBy(this))
Lines 2016-2021 Link Here
2016
		} catch (AbortCompilation e) {
2029
		} catch (AbortCompilation e) {
2017
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
2030
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
2018
			throw e;
2031
			throw e;
2032
		} finally {
2033
			env.missingClassFileLocation = null;
2019
		}
2034
		}
2020
	}
2035
	}
2021
2036
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-12 / +29 lines)
Lines 64-69 Link Here
64
	private SimpleLookupTable uniqueParameterizedGenericMethodBindings;
64
	private SimpleLookupTable uniqueParameterizedGenericMethodBindings;
65
	
65
	
66
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
66
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
67
	public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems
67
68
68
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
69
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
69
	private MethodVerifier verifier;
70
	private MethodVerifier verifier;
Lines 172-177 Link Here
172
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
173
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
173
	return null; // the type already exists & can be retrieved from the cache
174
	return null; // the type already exists & can be retrieved from the cache
174
}
175
}
176
public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName, CompilationUnitDeclaration unit) {
177
	// report the missing class file first
178
	problemReporter.isClassPathCorrect(
179
		compoundName, 
180
		unit == null ? this.unitBeingCompleted : unit, 
181
		this.missingClassFileLocation);
182
183
	PackageBinding packageBinding = computePackageFrom(compoundName);
184
	// create a proxy for the missing BinaryType
185
	MissingBinaryTypeBinding type = new MissingBinaryTypeBinding(packageBinding, compoundName, this);
186
	if (type.id != TypeIds.T_JavaLangObject) {
187
		// make Object be its superclass - it could in turn be missing as well
188
		ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT);
189
		if (objectType == null)
190
			objectType = cacheMissingBinaryType(TypeConstants.JAVA_LANG_OBJECT, unit);	// create a proxy for the missing Object type		
191
		type.setMissingSuperclass(objectType);
192
	}
193
	packageBinding.addType(type);
194
	return type;	
195
}
175
/*
196
/*
176
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
197
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
177
* 2. Create the field bindings
198
* 2. Create the field bindings
Lines 860-867 Link Here
860
	ReferenceBinding type = getType(compoundName);
881
	ReferenceBinding type = getType(compoundName);
861
	if (type != null) return type;
882
	if (type != null) return type;
862
883
863
	problemReporter.isClassPathCorrect(compoundName, scope == null ? null : scope.referenceCompilationUnit());
884
	// create a proxy for the missing BinaryType
864
	return null; // will not get here since the above error aborts the compilation
885
	return cacheMissingBinaryType(
886
		compoundName, 
887
		scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit());
865
}
888
}
866
/* Answer the top level package named name.
889
/* Answer the top level package named name.
867
* Ask the oracle for the package if its not in the cache.
890
* Ask the oracle for the package if its not in the cache.
Lines 886-892 Link Here
886
}
909
}
887
/* Answer the type corresponding to the compoundName.
910
/* Answer the type corresponding to the compoundName.
888
* Ask the name environment for the type if its not in the cache.
911
* Ask the name environment for the type if its not in the cache.
889
* Answer null if the type cannot be found... likely a fatal error.
912
* Answer null if the type cannot be found.
890
*/
913
*/
891
914
892
public ReferenceBinding getType(char[][] compoundName) {
915
public ReferenceBinding getType(char[][] compoundName) {
Lines 947-954 Link Here
947
* unresolved type is returned which must be resolved before used.
970
* unresolved type is returned which must be resolved before used.
948
*
971
*
949
* NOTE: Does NOT answer base types nor array types!
972
* NOTE: Does NOT answer base types nor array types!
950
*
951
* NOTE: Aborts compilation if the class file cannot be found.
952
*/
973
*/
953
974
954
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) {
975
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) {
Lines 958-968 Link Here
958
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
979
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
959
		packageBinding.addType(binding);
980
		packageBinding.addType(binding);
960
	} else if (binding == TheNotFoundType) {
981
	} else if (binding == TheNotFoundType) {
961
		problemReporter.isClassPathCorrect(compoundName, null);
982
		// create a proxy for the missing BinaryType
962
		return null; // will not get here since the above error aborts the compilation
983
		binding = cacheMissingBinaryType(compoundName, this.unitBeingCompleted);
963
	} else if (!isParameterized) {
984
	} else if (!isParameterized) {
964
	    // check raw type, only for resolved types
985
	    // check raw type, only for resolved types
965
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
986
        binding = (ReferenceBinding) convertUnresolvedBinaryToRawType(binding);
966
	}
987
	}
967
	return binding;
988
	return binding;
968
}
989
}
Lines 971-978 Link Here
971
* unresolved type is returned which must be resolved before used.
992
* unresolved type is returned which must be resolved before used.
972
*
993
*
973
* NOTE: Does NOT answer base types nor array types!
994
* NOTE: Does NOT answer base types nor array types!
974
*
975
* NOTE: Aborts compilation if the class file cannot be found.
976
*/
995
*/
977
996
978
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) {
997
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) {
Lines 987-994 Link Here
987
* unresolved type is returned which must be resolved before used.
1006
* unresolved type is returned which must be resolved before used.
988
*
1007
*
989
* NOTE: Does answer base types & array types.
1008
* NOTE: Does answer base types & array types.
990
*
991
* NOTE: Aborts compilation if the class file cannot be found.
992
*/
1009
*/
993
1010
994
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) {
1011
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) {
(-)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
			// create a proxy for the missing BinaryType
46
		} else {
46
			targetType = environment.cacheMissingBinaryType(this.compoundName, null);
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/BinaryTypeBinding.java (-14 / +32 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 908-913 Link Here
908
	// finish resolving the type
921
	// finish resolving the type
909
	this.superclass = resolveType(this.superclass, this.environment, true);
922
	this.superclass = resolveType(this.superclass, this.environment, true);
910
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
923
	this.tagBits &= ~TagBits.HasUnresolvedSuperclass;
924
	if (this.superclass.problemId() == ProblemReasons.NotFound)
925
		this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
911
	return this.superclass;
926
	return this.superclass;
912
}
927
}
913
// NOTE: superInterfaces of binary types are resolved when needed
928
// NOTE: superInterfaces of binary types are resolved when needed
Lines 915-922 Link Here
915
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
930
	if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0)
916
		return this.superInterfaces;
931
		return this.superInterfaces;
917
932
918
	for (int i = this.superInterfaces.length; --i >= 0;)
933
	for (int i = this.superInterfaces.length; --i >= 0;) {
919
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
934
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
935
		if (this.superInterfaces[i].problemId() == ProblemReasons.NotFound)
936
			this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
937
	}
920
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
938
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
921
	return this.superInterfaces;
939
	return this.superInterfaces;
922
}
940
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-3 / +5 lines)
Lines 558-566 Link Here
558
	if (importBinding != null)
558
	if (importBinding != null)
559
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
559
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
560
560
561
	// abort if java.lang cannot be found...
561
	if (importBinding == null || !importBinding.isValidBinding()) {
562
	if (importBinding == null || !importBinding.isValidBinding())
562
		// create a proxy for the missing BinaryType
563
		problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
563
		BinaryTypeBinding missingObject = environment.cacheMissingBinaryType(JAVA_LANG_OBJECT, this.referenceContext);
564
		importBinding = missingObject.fPackage;
565
	}
564
566
565
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
567
	return environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
566
}
568
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java (+4 lines)
Lines 34-40 Link Here
34
	}
34
	}
35
35
36
	protected TypeBinding findNextTypeBinding(int tokenIndex, Scope scope, PackageBinding packageBinding) {
36
	protected TypeBinding findNextTypeBinding(int tokenIndex, Scope scope, PackageBinding packageBinding) {
37
		LookupEnvironment env = scope.environment();
37
		try {
38
		try {
39
			env.missingClassFileLocation = this;
38
		    if (this.resolvedType == null) {
40
		    if (this.resolvedType == null) {
39
				this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding);
41
				this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding);
40
		    } else {
42
		    } else {
Lines 51-56 Link Here
51
		} catch (AbortCompilation e) {
53
		} catch (AbortCompilation e) {
52
			e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
54
			e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
53
			throw e;
55
			throw e;
56
		} finally {
57
			env.missingClassFileLocation = null;
54
		}
58
		}
55
	}
59
	}
56
60
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java (-2 / +2 lines)
Lines 115-122 Link Here
115
		}
115
		}
116
		if (exceptionType.findSuperTypeErasingTo(TypeIds.T_JavaLangThrowable, true) == null) {
116
		if (exceptionType.findSuperTypeErasingTo(TypeIds.T_JavaLangThrowable, true) == null) {
117
			scope.problemReporter().cannotThrowType(this.type, exceptionType);
117
			scope.problemReporter().cannotThrowType(this.type, exceptionType);
118
			return null;
118
			// fall thru to create the variable - avoids additional errors because the variable is missing
119
		}			
119
		}
120
		
120
		
121
		Binding existingVariable = scope.getBinding(name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
121
		Binding existingVariable = scope.getBinding(name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
122
		if (existingVariable != null && existingVariable.isValidBinding()){
122
		if (existingVariable != null && existingVariable.isValidBinding()){
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java (+4 lines)
Lines 54-65 Link Here
54
		if (this.dimensions > 255) {
54
		if (this.dimensions > 255) {
55
			scope.problemReporter().tooManyDimensions(this);
55
			scope.problemReporter().tooManyDimensions(this);
56
		}
56
		}
57
		LookupEnvironment env = scope.environment();
57
		try {
58
		try {
59
			env.missingClassFileLocation = this;
58
			TypeBinding leafComponentType = super.getTypeBinding(scope);
60
			TypeBinding leafComponentType = super.getTypeBinding(scope);
59
			return this.resolvedType = scope.createArrayType(leafComponentType, dimensions);
61
			return this.resolvedType = scope.createArrayType(leafComponentType, dimensions);
60
		} catch (AbortCompilation e) {
62
		} catch (AbortCompilation e) {
61
			e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
63
			e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
62
			throw e;
64
			throw e;
65
		} finally {
66
			env.missingClassFileLocation = null;
63
		}
67
		}
64
	}
68
	}
65
	
69
	
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-5 / +17 lines)
Lines 3318-3324 Link Here
3318
		if (isRecoveredName(ref.tokens)) return;
3318
		if (isRecoveredName(ref.tokens)) return;
3319
		if (type instanceof ReferenceBinding) {
3319
		if (type instanceof ReferenceBinding) {
3320
			char[][] name = ((ReferenceBinding) type).compoundName;
3320
			char[][] name = ((ReferenceBinding) type).compoundName;
3321
			end = (int) ref.sourcePositions[name.length - 1];
3321
			if (name.length <= ref.sourcePositions.length)
3322
				end = (int) ref.sourcePositions[name.length - 1];
3322
		}
3323
		}
3323
	} else if (location instanceof ImportReference) {
3324
	} else if (location instanceof ImportReference) {
3324
		ImportReference ref = (ImportReference) location;
3325
		ImportReference ref = (ImportReference) location;
Lines 3443-3458 Link Here
3443
		argument.type.sourceStart,
3444
		argument.type.sourceStart,
3444
		argument.sourceEnd);
3445
		argument.sourceEnd);
3445
}
3446
}
3446
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3447
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location) {
3447
	this.referenceContext = compUnitDecl;
3448
	this.referenceContext = compUnitDecl;
3448
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3449
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3450
	int start = 0, end = 0;
3451
	if (location != null) {
3452
		if (location instanceof InvocationSite) {
3453
			InvocationSite site = (InvocationSite) location;
3454
			start = site.sourceStart();
3455
			end = site.sourceEnd();
3456
		} else if (location instanceof ASTNode) {
3457
			ASTNode node = (ASTNode) location;
3458
			start = node.sourceStart();
3459
			end = node.sourceEnd();
3460
		}
3461
	}
3449
	this.handle(
3462
	this.handle(
3450
		IProblem.IsClassPathCorrect,
3463
		IProblem.IsClassPathCorrect,
3451
		arguments, 
3464
		arguments, 
3452
		arguments,
3465
		arguments,
3453
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3466
		start,
3454
		0,
3467
		end);
3455
		0);
3456
}
3468
}
3457
private boolean isIdentifier(int token) {
3469
private boolean isIdentifier(int token) {
3458
	return token == TerminalTokens.TokenNameIdentifier;
3470
	return token == TerminalTokens.TokenNameIdentifier;
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (-1 / +4 lines)
Lines 594-599 Link Here
594
	 * Process a compilation unit already parsed and build.
594
	 * Process a compilation unit already parsed and build.
595
	 */
595
	 */
596
	public void process(CompilationUnitDeclaration unit, int i) {
596
	public void process(CompilationUnitDeclaration unit, int i) {
597
		this.lookupEnvironment.unitBeingCompleted = unit;
598
597
		this.parser.getMethodBodies(unit);
599
		this.parser.getMethodBodies(unit);
598
600
599
		// fault in fields & methods
601
		// fault in fields & methods
Lines 619-626 Link Here
619
621
620
		// refresh the total number of units known at this stage
622
		// refresh the total number of units known at this stage
621
		unit.compilationResult.totalUnitsKnown = totalUnits;
623
		unit.compilationResult.totalUnitsKnown = totalUnits;
624
625
		this.lookupEnvironment.unitBeingCompleted = null;
622
	}
626
	}
623
	
624
627
625
	protected void processAnnotations(ICompilationUnit[] sourceUnits) {
628
	protected void processAnnotations(ICompilationUnit[] sourceUnits) {
626
		int newUnitSize = 0;
629
		int newUnitSize = 0;
(-)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--) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MissingBinaryTypeBinding.java (+58 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.ast.CompilationUnitDeclaration;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
17
public class MissingBinaryTypeBinding extends BinaryTypeBinding {
18
19
/**
20
 * Special constructor for constructing proxies of missing binary types (114349)
21
 * @param packageBinding
22
 * @param compoundName
23
 * @param environment
24
 */
25
public MissingBinaryTypeBinding(PackageBinding packageBinding, char[][] compoundName, LookupEnvironment environment) {
26
	this.compoundName = compoundName;
27
	computeId();
28
	this.tagBits |= TagBits.IsBinaryBinding | TagBits.HierarchyHasProblems;
29
	this.environment = environment;
30
	this.fPackage = packageBinding;
31
	this.fileName = CharOperation.concatWith(compoundName, '/');
32
	this.sourceName = compoundName[compoundName.length - 1]; // [java][util][Map$Entry]
33
	this.modifiers = ClassFileConstants.AccPublic;
34
	this.superclass = null; // will be fixed up using #setMissingSuperclass(...)
35
	this.superInterfaces = Binding.NO_SUPERINTERFACES;
36
	this.typeVariables = Binding.NO_TYPE_VARIABLES;
37
	this.memberTypes = Binding.NO_MEMBER_TYPES;
38
	this.fields = Binding.NO_FIELDS;
39
	this.methods = Binding.NO_METHODS;
40
}	
41
	
42
/**
43
 * Missing binary type will answer <code>false</code> to #isValidBinding()
44
 * @see org.eclipse.jdt.internal.compiler.lookup.Binding#problemId()
45
 */
46
public int problemId() {
47
	return ProblemReasons.NotFound;
48
}
49
50
/**
51
 * Only used to fixup the superclass hierarchy of proxy binary types
52
 * @param missingSuperclass
53
 * @see LookupEnvironment#cacheMissingBinaryType(char[][], CompilationUnitDeclaration)
54
 */
55
void setMissingSuperclass(ReferenceBinding missingSuperclass) {
56
	this.superclass = missingSuperclass;
57
}	
58
}
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (+5 lines)
Lines 15483-15488 Link Here
15483
		"	bar().missing();\n" + 
15483
		"	bar().missing();\n" + 
15484
		"	^^^^^^^^^^^^^^^\n" + 
15484
		"	^^^^^^^^^^^^^^^\n" + 
15485
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15485
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15486
		"----------\n" + 
15487
		"2. ERROR in plugin1\\Main.java (at line 5)\n" + 
15488
		"	bar().missing();\n" + 
15489
		"	      ^^^^^^^\n" + 
15490
		"The method missing() is undefined for the type Dumbo\n" + 
15486
		"----------\n",
15491
		"----------\n",
15487
		null,
15492
		null,
15488
		false);
15493
		false);
(-)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/builder/DependencyTests.java (+71 lines)
Lines 806-811 Link Here
806
		expectingNoProblems();
806
		expectingNoProblems();
807
	}
807
	}
808
808
809
	public void testMissingClassFile() throws JavaModelException {
810
		IPath project1Path = env.addProject("Project1"); //$NON-NLS-1$
811
		env.addExternalJars(project1Path, Util.getJavaClassLibs());
812
813
		// remove old package fragment root so that names don't collide
814
		env.removePackageFragmentRoot(project1Path,""); //$NON-NLS-1$
815
816
		IPath root1 = env.addPackageFragmentRoot(project1Path, "src"); //$NON-NLS-1$
817
		env.setOutputFolder(project1Path, "bin"); //$NON-NLS-1$
818
819
		env.addClass(root1, "p1", "MissingClass", //$NON-NLS-1$ //$NON-NLS-2$
820
			"package p1;\n"+ //$NON-NLS-1$
821
			"public class MissingClass {}" //$NON-NLS-1$
822
		);
823
824
		IPath project2Path = env.addProject("Project2"); //$NON-NLS-1$
825
		env.addExternalJars(project2Path, Util.getJavaClassLibs());
826
		env.addRequiredProject(project2Path, project1Path);
827
828
		// remove old package fragment root so that names don't collide
829
		env.removePackageFragmentRoot(project2Path,""); //$NON-NLS-1$
830
831
		IPath root2 = env.addPackageFragmentRoot(project2Path, "src"); //$NON-NLS-1$
832
		env.setOutputFolder(project2Path, "bin"); //$NON-NLS-1$
833
834
		env.addClass(root2, "p2", "A", //$NON-NLS-1$ //$NON-NLS-2$
835
			"package p2;\n"+ //$NON-NLS-1$
836
			"import p1.MissingClass;\n" +
837
			"public class A {\n"+ //$NON-NLS-1$
838
			"	public void foo(MissingClass data) {}\n"+ //$NON-NLS-1$
839
			"	public void foo(String data) {}\n"+ //$NON-NLS-1$
840
			"}\n" //$NON-NLS-1$
841
		);
842
843
		IPath project3Path = env.addProject("Project3"); //$NON-NLS-1$
844
		env.addExternalJars(project3Path, Util.getJavaClassLibs());
845
		env.addRequiredProject(project3Path, project2Path);
846
		// missing required Project1 so MissingClass cannot be found
847
848
		// remove old package fragment root so that names don't collide
849
		env.removePackageFragmentRoot(project3Path,""); //$NON-NLS-1$
850
851
		IPath root3 = env.addPackageFragmentRoot(project3Path, "src"); //$NON-NLS-1$
852
		env.setOutputFolder(project3Path, "bin"); //$NON-NLS-1$
853
	
854
		IPath bPath = env.addClass(root3, "p3", "B", //$NON-NLS-1$ //$NON-NLS-2$
855
			"package p3;\n"+ //$NON-NLS-1$
856
			"import p2.A;\n" +
857
			"public class B {\n"+ //$NON-NLS-1$
858
			"	public static void main(String[] args) {\n" + //$NON-NLS-1$
859
			"		new A().foo(new String());\n" + //$NON-NLS-1$
860
			"	}\n" + //$NON-NLS-1$
861
			"}\n" //$NON-NLS-1$
862
		);
863
864
		fullBuild();
865
		expectingOnlyProblemsFor(new IPath[] {project3Path, bPath});
866
		expectingSpecificProblemFor(project3Path, new Problem("Project3", "The project was not built since its build path is incomplete. Cannot find the class file for p1.MissingClass. Fix the build path then try building this project", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH)); //$NON-NLS-1$ //$NON-NLS-2$
867
		expectingSpecificProblemFor(bPath, new Problem("B", "The type p1.MissingClass cannot be resolved. It is indirectly referenced from required .class files", bPath, 86, 111, CategorizedProblem.CAT_BUILDPATH)); //$NON-NLS-1$ //$NON-NLS-2$
868
869
		env.addClass(root2, "p2", "A", //$NON-NLS-1$ //$NON-NLS-2$
870
			"package p2;\n"+ //$NON-NLS-1$
871
			"public class A {\n"+ //$NON-NLS-1$
872
			"	public void foo(String data) {}\n"+ //$NON-NLS-1$
873
			"}\n" //$NON-NLS-1$
874
		);
875
876
		incrementalBuild();
877
		expectingNoProblems();
878
	}
879
809
	// 72468
880
	// 72468
810
	public void testTypeDeleting() throws JavaModelException {
881
	public void testTypeDeleting() throws JavaModelException {
811
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
882
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +2 lines)
Lines 6087-6094 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, 2, expectedResult);
6092
		compilationUnit.accept(new ASTVisitor() {
6093
		compilationUnit.accept(new ASTVisitor() {
6093
			public void endVisit(MethodDeclaration methodDeclaration) {
6094
			public void endVisit(MethodDeclaration methodDeclaration) {
6094
				Block body = methodDeclaration.getBody();
6095
				Block body = methodDeclaration.getBody();

Return to bug 114349