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

Collapse All | Expand All

(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (+5 lines)
Lines 15482-15487 Link Here
15482
		"	bar().missing();\n" + 
15482
		"	bar().missing();\n" + 
15483
		"	^^^^^^^^^^^^^^^\n" + 
15483
		"	^^^^^^^^^^^^^^^\n" + 
15484
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15484
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15485
		"----------\n" + 
15486
		"2. ERROR in plugin1\\Main.java (at line 5)\n" + 
15487
		"	bar().missing();\n" + 
15488
		"	      ^^^^^^^\n" + 
15489
		"The method missing() is undefined for the type Dumbo\n" + 
15485
		"----------\n",
15490
		"----------\n",
15486
		null,
15491
		null,
15487
		false);
15492
		false);
(-)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();
(-)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 (+79 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
		IPath output1 = 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
		fullBuild(project1Path);
825
		expectingNoProblems();
826
827
		IPath project2Path = env.addProject("Project2"); //$NON-NLS-1$
828
		env.addExternalJars(project2Path, Util.getJavaClassLibs());
829
		env.addRequiredProject(project2Path, project1Path);
830
831
		// remove old package fragment root so that names don't collide
832
		env.removePackageFragmentRoot(project2Path,""); //$NON-NLS-1$
833
834
		IPath root2 = env.addPackageFragmentRoot(project2Path, "src"); //$NON-NLS-1$
835
		env.setOutputFolder(project2Path, "bin"); //$NON-NLS-1$
836
837
		env.addClass(root2, "p2", "A", //$NON-NLS-1$ //$NON-NLS-2$
838
			"package p2;\n"+ //$NON-NLS-1$
839
			"import p1.MissingClass;\n" +
840
			"public class A {\n"+ //$NON-NLS-1$
841
			"	public void foo(MissingClass data) {}\n"+ //$NON-NLS-1$
842
			"	public void foo(String data) {}\n"+ //$NON-NLS-1$
843
			"}\n" //$NON-NLS-1$
844
		);
845
846
		fullBuild(project2Path);
847
		expectingNoProblems();
848
849
		// delete binary file MissingClass (i.e. simulate removing it from classpath for subsequent compile)
850
		new java.io.File(output1.toString(), "p1" + java.io.File.separator + "MissingClass.class").delete();
851
852
		IPath project3Path = env.addProject("Project3"); //$NON-NLS-1$
853
		env.addExternalJars(project3Path, Util.getJavaClassLibs());
854
		env.addRequiredProject(project3Path, project2Path);
855
856
		// remove old package fragment root so that names don't collide
857
		env.removePackageFragmentRoot(project3Path,""); //$NON-NLS-1$
858
859
		IPath root3 = env.addPackageFragmentRoot(project3Path, "src"); //$NON-NLS-1$
860
		env.setOutputFolder(project3Path, "bin"); //$NON-NLS-1$
861
	
862
		IPath bPath = env.addClass(root3, "p3", "B", //$NON-NLS-1$ //$NON-NLS-2$
863
			"package p3;\n"+ //$NON-NLS-1$
864
			"import p2.A;\n" +
865
			"public class B {\n"+ //$NON-NLS-1$
866
			"	public static void main(String[] args) {\n" + //$NON-NLS-1$
867
			"		new A().foo(new String());\n" + //$NON-NLS-1$
868
			"	}\n" + //$NON-NLS-1$
869
			"}\n" //$NON-NLS-1$
870
		);
871
872
		fullBuild(project3Path);
873
		expectingOnlyProblemsFor(new IPath[] {project3Path, bPath});
874
		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$
875
		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$
876
877
		env.addClass(root2, "p2", "A", //$NON-NLS-1$ //$NON-NLS-2$
878
			"package p2;\n"+ //$NON-NLS-1$
879
			"public class A {\n"+ //$NON-NLS-1$
880
			"	public void foo(String data) {}\n"+ //$NON-NLS-1$
881
			"}\n" //$NON-NLS-1$
882
		);
883
884
		incrementalBuild();
885
		expectingNoProblems();
886
	}
887
809
	// 72468
888
	// 72468
810
	public void testTypeDeleting() throws JavaModelException {
889
	public void testTypeDeleting() throws JavaModelException {
811
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
890
		IPath projectPath = env.addProject("Project"); //$NON-NLS-1$
(-)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
}
(-)model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java (-11 / +14 lines)
Lines 177-182 Link Here
177
					// if the output location changes, do not delete the binary files from old location
177
					// if the output location changes, do not delete the binary files from old location
178
					// the user may be trying something
178
					// the user may be trying something
179
					buildAll();
179
					buildAll();
180
				} else if (hasBuildpathErrors()) {
181
					// if a mssing class file was detected in the last build, a build state was saved since its no longer fatal
182
					// BUT we still need a full build to fix up the project
183
					buildAll();
180
				} else if (nameEnvironment.sourceLocations.length > 0) {
184
				} else if (nameEnvironment.sourceLocations.length > 0) {
181
					// if there is no source to compile & no classpath changes then we are done
185
					// if there is no source to compile & no classpath changes then we are done
182
					SimpleLookupTable deltas = findDeltas();
186
					SimpleLookupTable deltas = findDeltas();
Lines 212-226 Link Here
212
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
216
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
213
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
217
		marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
214
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
218
		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) {
219
	} catch (MissingSourceFileException e) {
225
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
220
		// do not log this exception since its thrown to handle aborted compiles because of missing source files
226
		if (DEBUG)
221
		if (DEBUG)
Lines 291-297 Link Here
291
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
286
		IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
292
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
287
		marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage())); 
293
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
288
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
294
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);		
289
		marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
295
	} finally {
290
	} finally {
296
		notifier.done();
291
		notifier.done();
297
		cleanup();
292
		cleanup();
Lines 438-443 Link Here
438
	return result;
433
	return result;
439
}
434
}
440
435
436
private boolean hasBuildpathErrors() throws CoreException {
437
	IMarker[] markers = this.currentProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
438
	for (int i = 0, l = markers.length; i < l; i++)
439
		if (markers[i].getAttribute(IJavaModelMarker.CATEGORY_ID, -1) == CategorizedProblem.CAT_BUILDPATH)
440
			return true;
441
	return false;
442
}
443
441
private boolean hasClasspathChanged() {
444
private boolean hasClasspathChanged() {
442
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
445
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
443
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
446
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
Lines 591-597 Link Here
591
private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
594
private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
592
	IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
595
	IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
593
	for (int i = 0, l = markers.length; i < l; i++)
596
	for (int i = 0, l = markers.length; i < l; i++)
594
		if (((Integer) markers[i].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR)
597
		if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR)
595
			return true;
598
			return true;
596
	return false;
599
	return false;
597
}
600
}
(-)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 / +28 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 550-574 Link Here
550
 */
552
 */
551
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
553
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
552
	if (sourceFile == null || problems == null || problems.length == 0) return;
554
	if (sourceFile == null || problems == null || problems.length == 0) return;
555
	 // once a classpath error is found, ignore all other problems for this project so the user can see the main error
556
	// but still try to compile as many source files as possible to help the case when the base libraries are in source
557
	if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
553
558
554
	String missingClassFile = null;
555
	IResource resource = sourceFile.resource;
559
	IResource resource = sourceFile.resource;
556
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
560
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
557
	for (int i = 0, l = problems.length; i < l; i++) {
561
	for (int i = 0, l = problems.length; i < l; i++) {
558
		CategorizedProblem problem = problems[i];
562
		CategorizedProblem problem = problems[i];
559
		int id = problem.getID();
563
		int id = problem.getID();
564
565
		// handle missing classfile situation
560
		if (id == IProblem.IsClassPathCorrect) {
566
		if (id == IProblem.IsClassPathCorrect) {
561
			JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
567
			String missingClassfileName = problem.getArguments()[0];
562
			String[] args = problem.getArguments();
568
			if (JavaBuilder.DEBUG)
563
			missingClassFile = args[0];
569
				System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
570
			boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
571
			// insert extra classpath problem, and make it the only problem for this project (optional)
572
			if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
573
				JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
574
				this.keepStoringProblemMarkers = false;
575
			}
576
			IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
577
			marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); 
578
			marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
579
			marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
580
			marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY);
581
			// even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
582
			// IsClassPathCorrect problem gets recorded since it may help locate the offending reference
564
		}
583
		}
565
		
584
566
		String markerType = problem.getMarkerType();
585
		String markerType = problem.getMarkerType();
567
		boolean managedProblem = false;
586
		boolean managedProblem = false;
568
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
587
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
569
				|| (managedProblem = managedMarkerTypes.contains(markerType))) {			
588
				|| (managedProblem = managedMarkerTypes.contains(markerType))) {
570
			IMarker marker = resource.createMarker(markerType);
589
			IMarker marker = resource.createMarker(markerType);
571
			
590
572
			// standard attributes
591
			// standard attributes
573
			marker.setAttributes(
592
			marker.setAttributes(
574
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
593
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
Lines 593-601 Link Here
593
			if (extraLength > 0) {
612
			if (extraLength > 0) {
594
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
613
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
595
			}
614
			}
615
616
			if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
596
		}
617
		}
597
		if (missingClassFile != null)
598
			throw new MissingClassFileException(missingClassFile);
599
	}
618
	}
600
}
619
}
601
620
(-)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/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 (-4 / +15 lines)
Lines 3443-3458 Link Here
3443
		argument.type.sourceStart,
3443
		argument.type.sourceStart,
3444
		argument.sourceEnd);
3444
		argument.sourceEnd);
3445
}
3445
}
3446
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3446
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location) {
3447
	this.referenceContext = compUnitDecl;
3447
	this.referenceContext = compUnitDecl;
3448
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3448
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3449
	int start = 0, end = 0;
3450
	if (location != null) {
3451
		if (location instanceof InvocationSite) {
3452
			InvocationSite site = (InvocationSite) location;
3453
			start = site.sourceStart();
3454
			end = site.sourceEnd();
3455
		} else if (location instanceof ASTNode) {
3456
			ASTNode node = (ASTNode) location;
3457
			start = node.sourceStart();
3458
			end = node.sourceEnd();
3459
		}
3460
	}
3449
	this.handle(
3461
	this.handle(
3450
		IProblem.IsClassPathCorrect,
3462
		IProblem.IsClassPathCorrect,
3451
		arguments, 
3463
		arguments, 
3452
		arguments,
3464
		arguments,
3453
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3465
		start,
3454
		0,
3466
		end);
3455
		0);
3456
}
3467
}
3457
private boolean isIdentifier(int token) {
3468
private boolean isIdentifier(int token) {
3458
	return token == TerminalTokens.TokenNameIdentifier;
3469
	return token == TerminalTokens.TokenNameIdentifier;
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (+3 lines)
Lines 584-589 Link Here
584
	 * Process a compilation unit already parsed and build.
584
	 * Process a compilation unit already parsed and build.
585
	 */
585
	 */
586
	public void process(CompilationUnitDeclaration unit, int i) {
586
	public void process(CompilationUnitDeclaration unit, int i) {
587
		this.lookupEnvironment.unitBeingCompleted = unit;
587
588
588
		this.parser.getMethodBodies(unit);
589
		this.parser.getMethodBodies(unit);
589
590
Lines 610-615 Link Here
610
611
611
		// refresh the total number of units known at this stage
612
		// refresh the total number of units known at this stage
612
		unit.compilationResult.totalUnitsKnown = totalUnits;
613
		unit.compilationResult.totalUnitsKnown = totalUnits;
614
615
		this.lookupEnvironment.unitBeingCompleted = null;
613
	}
616
	}
614
	public void reset() {
617
	public void reset() {
615
		lookupEnvironment.reset();
618
		lookupEnvironment.reset();
(-)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
}

Return to bug 114349