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 15478-15483 Link Here
15478
		"	bar().missing();\n" + 
15478
		"	bar().missing();\n" + 
15479
		"	^^^^^^^^^^^^^^^\n" + 
15479
		"	^^^^^^^^^^^^^^^\n" + 
15480
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15480
		"The type plugin3.SecretClass cannot be resolved. It is indirectly referenced from required .class files\n" + 
15481
		"----------\n" + 
15482
		"2. ERROR in plugin1\\Main.java (at line 5)\n" + 
15483
		"	bar().missing();\n" + 
15484
		"	      ^^^^^^^\n" + 
15485
		"The method missing() is undefined for the type Dumbo\n" + 
15481
		"----------\n",
15486
		"----------\n",
15482
		null,
15487
		null,
15483
		false);
15488
		false);
(-)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/builder/MultiProjectTests.java (-1 / +173 lines)
Lines 779-785 Link Here
779
			env.setBuildOrder(null);
779
			env.setBuildOrder(null);
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
	 */
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +2 lines)
Lines 6080-6087 Link Here
6080
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6080
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
6081
		CompilationUnit compilationUnit = (CompilationUnit) node;
6081
		CompilationUnit compilationUnit = (CompilationUnit) node;
6082
		String expectedResult = 
6082
		String expectedResult = 
6083
			"The hierarchy of the type X is inconsistent\n" + 
6083
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6084
			"The type test0599.Zork2 cannot be resolved. It is indirectly referenced from required .class files";
6084
		assertProblemsSize(compilationUnit, 1, expectedResult);
6085
		assertProblemsSize(compilationUnit, 2, expectedResult);
6085
		compilationUnit.accept(new ASTVisitor() {
6086
		compilationUnit.accept(new ASTVisitor() {
6086
			public void endVisit(MethodDeclaration methodDeclaration) {
6087
			public void endVisit(MethodDeclaration methodDeclaration) {
6087
				Block body = methodDeclaration.getBody();
6088
				Block body = methodDeclaration.getBody();
(-)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/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/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 173-178 Link Here
173
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
174
		return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction);
174
	return null; // the type already exists & can be retrieved from the cache
175
	return null; // the type already exists & can be retrieved from the cache
175
}
176
}
177
public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName, CompilationUnitDeclaration unit) {
178
	// report the missing class file first
179
	problemReporter.isClassPathCorrect(
180
		compoundName, 
181
		unit == null ? this.unitBeingCompleted : unit, 
182
		this.missingClassFileLocation);
183
184
	PackageBinding packageBinding = computePackageFrom(compoundName);
185
	// create a proxy for the missing BinaryType
186
	MissingBinaryTypeBinding type = new MissingBinaryTypeBinding(packageBinding, compoundName, this);
187
	if (type.id != TypeIds.T_JavaLangObject) {
188
		// make Object be its superclass - it could in turn be missing as well
189
		ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT);
190
		if (objectType == null)
191
			objectType = cacheMissingBinaryType(TypeConstants.JAVA_LANG_OBJECT, unit);	// create a proxy for the missing Object type		
192
		type.setMissingSuperclass(objectType);
193
	}
194
	packageBinding.addType(type);
195
	return type;	
196
}
176
/*
197
/*
177
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
198
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
178
* 2. Create the field bindings
199
* 2. Create the field bindings
Lines 859-866 Link Here
859
	ReferenceBinding type = getType(compoundName);
880
	ReferenceBinding type = getType(compoundName);
860
	if (type != null) return type;
881
	if (type != null) return type;
861
882
862
	problemReporter.isClassPathCorrect(compoundName, scope == null ? null : scope.referenceCompilationUnit());
883
	// create a proxy for the missing BinaryType
863
	return null; // will not get here since the above error aborts the compilation
884
	return cacheMissingBinaryType(
885
		compoundName, 
886
		scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit());
864
}
887
}
865
/* Answer the top level package named name.
888
/* Answer the top level package named name.
866
* Ask the oracle for the package if its not in the cache.
889
* Ask the oracle for the package if its not in the cache.
Lines 885-891 Link Here
885
}
908
}
886
/* Answer the type corresponding to the compoundName.
909
/* Answer the type corresponding to the compoundName.
887
* Ask the name environment for the type if its not in the cache.
910
* Ask the name environment for the type if its not in the cache.
888
* Answer null if the type cannot be found... likely a fatal error.
911
* Answer null if the type cannot be found.
889
*/
912
*/
890
913
891
public ReferenceBinding getType(char[][] compoundName) {
914
public ReferenceBinding getType(char[][] compoundName) {
Lines 946-953 Link Here
946
* unresolved type is returned which must be resolved before used.
969
* unresolved type is returned which must be resolved before used.
947
*
970
*
948
* NOTE: Does NOT answer base types nor array types!
971
* NOTE: Does NOT answer base types nor array types!
949
*
950
* NOTE: Aborts compilation if the class file cannot be found.
951
*/
972
*/
952
973
953
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) {
974
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) {
Lines 957-967 Link Here
957
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
978
		binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
958
		packageBinding.addType(binding);
979
		packageBinding.addType(binding);
959
	} else if (binding == TheNotFoundType) {
980
	} else if (binding == TheNotFoundType) {
960
		problemReporter.isClassPathCorrect(compoundName, null);
981
		// create a proxy for the missing BinaryType
961
		return null; // will not get here since the above error aborts the compilation
982
		binding = cacheMissingBinaryType(compoundName, this.unitBeingCompleted);
962
	} else if (!isParameterized) {
983
	} else if (!isParameterized) {
963
	    // check raw type, only for resolved types
984
	    // check raw type, only for resolved types
964
        binding = (ReferenceBinding)convertUnresolvedBinaryToRawType(binding);
985
        binding = (ReferenceBinding) convertUnresolvedBinaryToRawType(binding);
965
	}
986
	}
966
	return binding;
987
	return binding;
967
}
988
}
Lines 970-977 Link Here
970
* unresolved type is returned which must be resolved before used.
991
* unresolved type is returned which must be resolved before used.
971
*
992
*
972
* NOTE: Does NOT answer base types nor array types!
993
* NOTE: Does NOT answer base types nor array types!
973
*
974
* NOTE: Aborts compilation if the class file cannot be found.
975
*/
994
*/
976
995
977
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) {
996
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) {
Lines 986-993 Link Here
986
* unresolved type is returned which must be resolved before used.
1005
* unresolved type is returned which must be resolved before used.
987
*
1006
*
988
* NOTE: Does answer base types & array types.
1007
* NOTE: Does answer base types & array types.
989
*
990
* NOTE: Aborts compilation if the class file cannot be found.
991
*/
1008
*/
992
1009
993
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) {
1010
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-2 / +5 lines)
Lines 550-557 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
		// create a proxy for the missing BinaryType
555
		BinaryTypeBinding missingObject = environment.cacheMissingBinaryType(JAVA_LANG_OBJECT, this.referenceContext);
556
		importBinding = missingObject.fPackage;
557
	}
555
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
}
(-)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/Scope.java (-7 / +23 lines)
Lines 1360-1367 Link Here
1360
	 *	Limitations: cannot request FIELD independently of LOCAL, or vice versa
1360
	 *	Limitations: cannot request FIELD independently of LOCAL, or vice versa
1361
	 */
1361
	 */
1362
	public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) {
1362
	public Binding getBinding(char[] name, int mask, InvocationSite invocationSite, boolean needResolve) {
1363
1363
		CompilationUnitScope unitScope = compilationUnitScope();
1364
		LookupEnvironment env = unitScope.environment;
1364
		try {
1365
		try {
1366
			env.missingClassFileLocation = invocationSite;
1365
			Binding binding = null;
1367
			Binding binding = null;
1366
			FieldBinding problemField = null;
1368
			FieldBinding problemField = null;
1367
			if ((mask & Binding.VARIABLE) != 0) {
1369
			if ((mask & Binding.VARIABLE) != 0) {
Lines 1504-1510 Link Here
1504
1506
1505
				if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
1507
				if (compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
1506
					// at this point the scope is a compilation unit scope & need to check for imported static fields
1508
					// at this point the scope is a compilation unit scope & need to check for imported static fields
1507
					CompilationUnitScope unitScope = (CompilationUnitScope) scope;
1508
					ImportBinding[] imports = unitScope.imports;
1509
					ImportBinding[] imports = unitScope.imports;
1509
					if (imports != null) {
1510
					if (imports != null) {
1510
						// check single static imports
1511
						// check single static imports
Lines 1569-1576 Link Here
1569
					return binding;
1570
					return binding;
1570
				// answer the problem type binding if we are only looking for a type
1571
				// answer the problem type binding if we are only looking for a type
1571
			} else if ((mask & Binding.PACKAGE) != 0) {
1572
			} else if ((mask & Binding.PACKAGE) != 0) {
1572
				compilationUnitScope().recordSimpleReference(name);
1573
				unitScope.recordSimpleReference(name);
1573
				if ((binding = environment().getTopLevelPackage(name)) != null)
1574
				if ((binding = env.getTopLevelPackage(name)) != null)
1574
					return binding;
1575
					return binding;
1575
			}
1576
			}
1576
			if (problemField != null) return problemField;
1577
			if (problemField != null) return problemField;
Lines 1580-1591 Link Here
1580
		} catch (AbortCompilation e) {
1581
		} catch (AbortCompilation e) {
1581
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1582
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1582
			throw e;
1583
			throw e;
1584
		} finally {
1585
			env.missingClassFileLocation = null;
1583
		}
1586
		}
1584
	}
1587
	}
1585
1588
1586
	public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1589
	public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1590
		CompilationUnitScope unitScope = compilationUnitScope();
1591
		LookupEnvironment env = unitScope.environment;
1587
		try {
1592
		try {
1588
			CompilationUnitScope unitScope = compilationUnitScope();
1593
			env.missingClassFileLocation = invocationSite;
1589
			unitScope.recordTypeReference(receiverType);
1594
			unitScope.recordTypeReference(receiverType);
1590
			unitScope.recordTypeReferences(argumentTypes);
1595
			unitScope.recordTypeReferences(argumentTypes);
1591
			MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
1596
			MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
Lines 1640-1645 Link Here
1640
		} catch (AbortCompilation e) {
1645
		} catch (AbortCompilation e) {
1641
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1646
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1642
			throw e;
1647
			throw e;
1648
		} finally {
1649
			env.missingClassFileLocation = null;
1643
		}
1650
		}
1644
	}
1651
	}
1645
1652
Lines 1684-1690 Link Here
1684
	}
1691
	}
1685
1692
1686
	public FieldBinding getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
1693
	public FieldBinding getField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
1694
		LookupEnvironment env = environment();
1687
		try {
1695
		try {
1696
			env.missingClassFileLocation = invocationSite;
1688
			FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
1697
			FieldBinding field = findField(receiverType, fieldName, invocationSite, true /*resolve*/);
1689
			if (field != null) return field;
1698
			if (field != null) return field;
1690
	
1699
	
Lines 1695-1700 Link Here
1695
		} catch (AbortCompilation e) {
1704
		} catch (AbortCompilation e) {
1696
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1705
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
1697
			throw e;
1706
			throw e;
1707
		} finally {
1708
			env.missingClassFileLocation = null;
1698
		}			
1709
		}			
1699
	}
1710
	}
1700
	
1711
	
Lines 1970-1984 Link Here
1970
	}
1981
	}
1971
1982
1972
	public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1983
	public MethodBinding getMethod(TypeBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
1984
		CompilationUnitScope unitScope = compilationUnitScope();
1985
		LookupEnvironment env = unitScope.environment;
1973
		try {
1986
		try {
1987
			env.missingClassFileLocation = invocationSite;
1974
			switch (receiverType.kind()) {
1988
			switch (receiverType.kind()) {
1975
				case Binding.BASE_TYPE :
1989
				case Binding.BASE_TYPE :
1976
					return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
1990
					return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
1977
				case Binding.ARRAY_TYPE :
1991
				case Binding.ARRAY_TYPE :
1978
					compilationUnitScope().recordTypeReference(receiverType);
1992
					unitScope.recordTypeReference(receiverType);
1979
					return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
1993
					return findMethodForArray((ArrayBinding) receiverType, selector, argumentTypes, invocationSite);
1980
			}
1994
			}
1981
			compilationUnitScope().recordTypeReference(receiverType);
1995
			unitScope.recordTypeReference(receiverType);
1982
1996
1983
			ReferenceBinding currentType = (ReferenceBinding) receiverType;
1997
			ReferenceBinding currentType = (ReferenceBinding) receiverType;
1984
			if (!currentType.canBeSeenBy(this))
1998
			if (!currentType.canBeSeenBy(this))
Lines 2005-2010 Link Here
2005
		} catch (AbortCompilation e) {
2019
		} catch (AbortCompilation e) {
2006
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
2020
			e.updateContext(invocationSite, referenceCompilationUnit().compilationResult);
2007
			throw e;
2021
			throw e;
2022
		} finally {
2023
			env.missingClassFileLocation = null;
2008
		}
2024
		}
2009
	}
2025
	}
2010
2026
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-10 / +27 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 144-150 Link Here
144
	return type;
144
	return type;
145
}
145
}
146
146
147
/**
148
 * Default empty constructor for subclasses only.
149
 */
150
protected BinaryTypeBinding() {
151
	// only for subclasses
152
}
147
153
154
/**
155
 * Standard constructor for creating binary type bindings from binary models (classfiles)
156
 * @param packageBinding
157
 * @param binaryType
158
 * @param environment
159
 */
148
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
160
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) {
149
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
161
	this.compoundName = CharOperation.splitOn('/', binaryType.getName());
150
	computeId();
162
	computeId();
Lines 927-932 Link Here
927
939
928
	// finish resolving the type
940
	// finish resolving the type
929
	this.superclass = resolveType(this.superclass, this.environment, true);
941
	this.superclass = resolveType(this.superclass, this.environment, true);
942
	if (this.superclass.problemId() == ProblemReasons.NotFound)
943
		this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
930
	return this.superclass;
944
	return this.superclass;
931
}
945
}
932
// NOTE: superInterfaces of binary types are resolved when needed
946
// NOTE: superInterfaces of binary types are resolved when needed
Lines 938-945 Link Here
938
		this.superInterfaces[i] = resolveUnresolvedType(this.superInterfaces[i], this.environment, true);
952
		this.superInterfaces[i] = resolveUnresolvedType(this.superInterfaces[i], this.environment, true);
939
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
953
	this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces;
940
954
941
	for (int i = this.superInterfaces.length; --i >= 0;)
955
	for (int i = this.superInterfaces.length; --i >= 0;) {
942
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
956
		this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true);
957
		if (this.superInterfaces[i].problemId() == ProblemReasons.NotFound)
958
			this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency
959
	}
943
	return this.superInterfaces;
960
	return this.superInterfaces;
944
}
961
}
945
public TypeVariableBinding[] typeVariables() {
962
public TypeVariableBinding[] typeVariables() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-3 / +12 lines)
Lines 955-965 Link Here
955
				problemReporter().hierarchyHasProblems(sourceType);
955
				problemReporter().hierarchyHasProblems(sourceType);
956
		}
956
		}
957
		connectMemberTypes();
957
		connectMemberTypes();
958
		LookupEnvironment env = environment();
958
		try {
959
		try {
960
			env.missingClassFileLocation = referenceContext;
959
			checkForInheritedMemberTypes(sourceType);
961
			checkForInheritedMemberTypes(sourceType);
960
		} catch (AbortCompilation e) {
962
		} catch (AbortCompilation e) {
961
			e.updateContext(referenceContext, referenceCompilationUnit().compilationResult);
963
			e.updateContext(referenceContext, referenceCompilationUnit().compilationResult);
962
			throw e;
964
			throw e;
965
		} finally {
966
			env.missingClassFileLocation = null;
963
		}
967
		}
964
	}
968
	}
965
	
969
	
Lines 1097-1115 Link Here
1097
	}
1101
	}
1098
1102
1099
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1103
	private ReferenceBinding findSupertype(TypeReference typeReference) {
1104
		CompilationUnitScope unitScope = compilationUnitScope();
1105
		LookupEnvironment env = unitScope.environment;
1100
		try {
1106
		try {
1107
			env.missingClassFileLocation = typeReference;
1101
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1108
			typeReference.aboutToResolve(this); // allows us to trap completion & selection nodes
1102
			compilationUnitScope().recordQualifiedReference(typeReference.getTypeName());
1109
			unitScope.recordQualifiedReference(typeReference.getTypeName());
1103
			this.superTypeReference = typeReference;
1110
			this.superTypeReference = typeReference;
1104
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1111
			ReferenceBinding superType = (ReferenceBinding) typeReference.resolveSuperType(this);
1105
			this.superTypeReference = null;
1106
			return superType;
1112
			return superType;
1107
		} catch (AbortCompilation e) {
1113
		} catch (AbortCompilation e) {
1108
			SourceTypeBinding sourceType = this.referenceContext.binding;
1114
			SourceTypeBinding sourceType = this.referenceContext.binding;
1109
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1115
			if (sourceType.superInterfaces == null)  sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; // be more resilient for hierarchies (144976)
1110
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1116
			e.updateContext(typeReference, referenceCompilationUnit().compilationResult);
1111
			throw e;
1117
			throw e;
1112
		}			
1118
		} finally {
1119
			env.missingClassFileLocation = null;
1120
			this.superTypeReference = null;
1121
		}
1113
	}
1122
	}
1114
1123
1115
	/* Answer the problem reporter to use for raising new problems.
1124
	/* Answer the problem reporter to use for raising new problems.
(-)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/JavaBuilder.java (-8 / +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)
Lines 432-437 Link Here
432
	return result;
424
	return result;
433
}
425
}
434
426
427
boolean hasBuildpathErrors() throws CoreException {
428
	IMarker[] markers = this.currentProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
429
	for (int i = 0, l = markers.length; i < l; i++)
430
		if (markers[i].getAttribute(IJavaModelMarker.CATEGORY_ID, -1) == CategorizedProblem.CAT_BUILDPATH)
431
			return true;
432
	return false;
433
}
434
435
private boolean hasClasspathChanged() {
435
private boolean hasClasspathChanged() {
436
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
436
	ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
437
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
437
	ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
(-)model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java (-10 / +69 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 199-204 Link Here
199
	// noop
201
	// noop
200
}
202
}
201
203
204
protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {
205
	for (int i = 0, l = sourceLocations.length; i < l; i++) {
206
		final ClasspathMultiDirectory sourceLocation = sourceLocations[i];
207
		final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
208
		final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
209
		final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
210
		final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
211
		final IContainer outputFolder = sourceLocation.binaryFolder;
212
		final boolean isOutputFolder = sourceLocation.sourceFolder.equals(outputFolder);
213
		sourceLocation.sourceFolder.accept(
214
			new IResourceProxyVisitor() {
215
				public boolean visit(IResourceProxy proxy) throws CoreException {
216
					switch(proxy.getType()) {
217
						case IResource.FILE :
218
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
219
								IResource resource = proxy.requestResource();
220
								if (exclusionPatterns != null || inclusionPatterns != null)
221
									if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
222
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
223
							}
224
							return false;
225
						case IResource.FOLDER :
226
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
227
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
228
							IPath folderPath = null;
229
							if (isAlsoProject)
230
								if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false;
231
							if (!isOutputFolder) {
232
								if (folderPath == null)
233
									folderPath = proxy.requestFullPath();
234
								createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
235
							}
236
					}
237
					return true;
238
				}
239
			},
240
			IResource.NONE
241
		);
242
		notifier.checkCancel();
243
	}
244
}
245
202
protected void cleanUp() {
246
protected void cleanUp() {
203
	this.nameEnvironment.cleanup();
247
	this.nameEnvironment.cleanup();
204
248
Lines 545-568 Link Here
545
 */
589
 */
546
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
590
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
547
	if (sourceFile == null || problems == null || problems.length == 0) return;
591
	if (sourceFile == null || problems == null || problems.length == 0) return;
592
	 // once a classpath error is found, ignore all other problems for this project so the user can see the main error
593
	// but still try to compile as many source files as possible to help the case when the base libraries are in source
594
	if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
548
595
549
	String missingClassFile = null;
550
	IResource resource = sourceFile.resource;
596
	IResource resource = sourceFile.resource;
551
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
597
	HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
552
	for (int i = 0, l = problems.length; i < l; i++) {
598
	for (int i = 0, l = problems.length; i < l; i++) {
553
		CategorizedProblem problem = problems[i];
599
		CategorizedProblem problem = problems[i];
554
		int id = problem.getID();
600
		int id = problem.getID();
601
602
		// handle missing classfile situation
555
		if (id == IProblem.IsClassPathCorrect) {
603
		if (id == IProblem.IsClassPathCorrect) {
556
			JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
604
			String missingClassfileName = problem.getArguments()[0];
557
			String[] args = problem.getArguments();
605
			if (JavaBuilder.DEBUG)
558
			missingClassFile = args[0];
606
				System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
607
			boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true));
608
			// insert extra classpath problem, and make it the only problem for this project (optional)
609
			if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
610
				JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
611
				this.keepStoringProblemMarkers = false;
612
			}
613
			IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
614
			marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); 
615
			marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
616
			marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH);
617
			// even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
618
			// IsClassPathCorrect problem gets recorded since it may help locate the offending reference
559
		}
619
		}
560
		
620
561
		String markerType = problem.getMarkerType();
621
		String markerType = problem.getMarkerType();
562
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
622
		if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType)
563
				|| managedMarkerTypes.contains(markerType)) {			
623
				|| managedMarkerTypes.contains(markerType)) {
564
			IMarker marker = resource.createMarker(markerType);
624
			IMarker marker = resource.createMarker(markerType);
565
			
625
566
			// standard attributes
626
			// standard attributes
567
			marker.setAttributes(
627
			marker.setAttributes(
568
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
628
				JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES,
Lines 574-580 Link Here
574
					new Integer(problem.getSourceEnd() + 1), // end
634
					new Integer(problem.getSourceEnd() + 1), // end
575
					new Integer(problem.getSourceLineNumber()), // line
635
					new Integer(problem.getSourceLineNumber()), // line
576
					Util.getProblemArgumentsForMarker(problem.getArguments()), // arguments
636
					Util.getProblemArgumentsForMarker(problem.getArguments()), // arguments
577
					new Integer(problem.getCategoryID()), // category ID
637
					new Integer(problem.getCategoryID()) // category ID
578
				}
638
				}
579
			);
639
			);
580
			// optional extra attributes
640
			// optional extra attributes
Lines 583-591 Link Here
583
			if (extraLength > 0) {
643
			if (extraLength > 0) {
584
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
644
				marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues());
585
			}
645
			}
646
			if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
586
		}
647
		}
587
		if (missingClassFile != null)
588
			throw new MissingClassFileException(missingClassFile);
589
	}
648
	}
590
}
649
}
591
650
(-)model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java (-21 / +31 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;
(-)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
}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-5 / +17 lines)
Lines 3262-3268 Link Here
3262
		if (isRecoveredName(ref.tokens)) return;
3262
		if (isRecoveredName(ref.tokens)) return;
3263
		if (type instanceof ReferenceBinding) {
3263
		if (type instanceof ReferenceBinding) {
3264
			char[][] name = ((ReferenceBinding) type).compoundName;
3264
			char[][] name = ((ReferenceBinding) type).compoundName;
3265
			end = (int) ref.sourcePositions[name.length - 1];
3265
			if (name.length <= ref.sourcePositions.length)
3266
				end = (int) ref.sourcePositions[name.length - 1];
3266
		}
3267
		}
3267
	} else if (location instanceof ImportReference) {
3268
	} else if (location instanceof ImportReference) {
3268
		ImportReference ref = (ImportReference) location;
3269
		ImportReference ref = (ImportReference) location;
Lines 3387-3402 Link Here
3387
		argument.type.sourceStart,
3388
		argument.type.sourceStart,
3388
		argument.sourceEnd);
3389
		argument.sourceEnd);
3389
}
3390
}
3390
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
3391
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl, Object location) {
3391
	this.referenceContext = compUnitDecl;
3392
	this.referenceContext = compUnitDecl;
3392
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3393
	String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
3394
	int start = 0, end = 0;
3395
	if (location != null) {
3396
		if (location instanceof InvocationSite) {
3397
			InvocationSite site = (InvocationSite) location;
3398
			start = site.sourceStart();
3399
			end = site.sourceEnd();
3400
		} else if (location instanceof ASTNode) {
3401
			ASTNode node = (ASTNode) location;
3402
			start = node.sourceStart();
3403
			end = node.sourceEnd();
3404
		}
3405
	}
3393
	this.handle(
3406
	this.handle(
3394
		IProblem.IsClassPathCorrect,
3407
		IProblem.IsClassPathCorrect,
3395
		arguments, 
3408
		arguments, 
3396
		arguments,
3409
		arguments,
3397
		ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
3410
		start,
3398
		0,
3411
		end);
3399
		0);
3400
}
3412
}
3401
private boolean isIdentifier(int token) {
3413
private boolean isIdentifier(int token) {
3402
	return token == TerminalTokens.TokenNameIdentifier;
3414
	return token == TerminalTokens.TokenNameIdentifier;
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (+3 lines)
Lines 580-585 Link Here
580
	 * Process a compilation unit already parsed and build.
580
	 * Process a compilation unit already parsed and build.
581
	 */
581
	 */
582
	public void process(CompilationUnitDeclaration unit, int i) {
582
	public void process(CompilationUnitDeclaration unit, int i) {
583
		this.lookupEnvironment.unitBeingCompleted = unit;
583
584
584
		this.parser.getMethodBodies(unit);
585
		this.parser.getMethodBodies(unit);
585
586
Lines 606-611 Link Here
606
607
607
		// refresh the total number of units known at this stage
608
		// refresh the total number of units known at this stage
608
		unit.compilationResult.totalUnitsKnown = totalUnits;
609
		unit.compilationResult.totalUnitsKnown = totalUnits;
610
611
		this.lookupEnvironment.unitBeingCompleted = null;
609
	}
612
	}
610
	public void reset() {
613
	public void reset() {
611
		lookupEnvironment.reset();
614
		lookupEnvironment.reset();
(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (-22 / +28 lines)
Lines 155-187 Link Here
155
 */
155
 */
156
private IType findSuperClass(IGenericType type, ReferenceBinding typeBinding) {
156
private IType findSuperClass(IGenericType type, ReferenceBinding typeBinding) {
157
	ReferenceBinding superBinding = typeBinding.superclass();
157
	ReferenceBinding superBinding = typeBinding.superclass();
158
	
158
159
	if (superBinding != null) {
159
	if (superBinding != null) {
160
		superBinding = (ReferenceBinding) superBinding.erasure();
160
		superBinding = (ReferenceBinding) superBinding.erasure();
161
		if (superBinding.id == TypeIds.T_JavaLangObject && typeBinding.isHierarchyInconsistent()) {
161
		if (typeBinding.isHierarchyInconsistent()) {
162
			char[] superclassName;
162
			if (superBinding.problemId() == ProblemReasons.NotFound) {
163
			char separator;
163
				this.hasMissingSuperClass = true;
164
			if (type instanceof IBinaryType) {
164
				this.builder.hierarchy.missingTypes.add(new String(superBinding.sourceName)); // note: this could be Map$Entry
165
				superclassName = ((IBinaryType)type).getSuperclassName();
166
				separator = '/';
167
			} else if (type instanceof ISourceType) {
168
				superclassName = ((ISourceType)type).getSuperclassName();
169
				separator = '.';
170
			} else if (type instanceof HierarchyType) {
171
				superclassName = ((HierarchyType)type).superclassName;
172
				separator = '.';
173
			} else {
174
				return null;
165
				return null;
175
			}
166
			} else if ((superBinding.id == TypeIds.T_JavaLangObject)) {
176
			
167
				char[] superclassName;
177
			if (superclassName != null) { // check whether subclass of Object due to broken hierarchy (as opposed to explicitly extending it)
168
				char separator;
178
				int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
169
				if (type instanceof IBinaryType) {
179
				char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
170
					superclassName = ((IBinaryType)type).getSuperclassName();
180
				if (!CharOperation.equals(simpleName, TypeConstants.OBJECT)) {
171
					separator = '/';
181
					this.hasMissingSuperClass = true;
172
				} else if (type instanceof ISourceType) {
182
					this.builder.hierarchy.missingTypes.add(new String(simpleName));
173
					superclassName = ((ISourceType)type).getSuperclassName();
174
					separator = '.';
175
				} else if (type instanceof HierarchyType) {
176
					superclassName = ((HierarchyType)type).superclassName;
177
					separator = '.';
178
				} else {
183
					return null;
179
					return null;
184
				}
180
				}
181
				
182
				if (superclassName != null) { // check whether subclass of Object due to broken hierarchy (as opposed to explicitly extending it)
183
					int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
184
					char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
185
					if (!CharOperation.equals(simpleName, TypeConstants.OBJECT)) {
186
						this.hasMissingSuperClass = true;
187
						this.builder.hierarchy.missingTypes.add(new String(simpleName));
188
						return null;
189
					}
190
				}
185
			}
191
			}
186
		}
192
		}
187
		for (int t = this.typeIndex; t >= 0; t--) {
193
		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