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

Collapse All | Expand All

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

Return to bug 114349