### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.77 diff -u -r1.77 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 3 Dec 2007 13:57:21 -0000 1.77 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 19 Dec 2007 16:40:39 -0000 @@ -53,6 +53,7 @@ import org.eclipse.jdt.internal.compiler.parser.Parser; import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter; import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; +import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; import org.eclipse.jdt.internal.compiler.util.Messages; import org.eclipse.jdt.internal.core.*; @@ -72,6 +73,14 @@ private int typeIndex; private IGenericType[] typeModels; + private static final CompilationUnitDeclaration FakeUnit; + static { + IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); + ProblemReporter problemReporter = new ProblemReporter(policy, new CompilerOptions(), new DefaultProblemFactory()); + CompilationResult result = new CompilationResult(CharOperation.NO_CHAR, 0, 0, 0); + FakeUnit = new CompilationUnitDeclaration(problemReporter, result, 0); + } + public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); @@ -699,13 +708,21 @@ for (int i = 0; i <= this.typeIndex; i++) { IGenericType suppliedType = this.typeModels[i]; if (suppliedType != null && suppliedType.isBinaryType()) { + CompilationUnitDeclaration previousUnitBeingCompleted = this.lookupEnvironment.unitBeingCompleted; // fault in its hierarchy... try { + // ensure that unitBeingCompleted is set so that we don't get an AbortCompilation for a missing type + // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213249 ) + if (previousUnitBeingCompleted == null) { + this.lookupEnvironment.unitBeingCompleted = FakeUnit; + } ReferenceBinding typeBinding = this.typeBindings[i]; typeBinding.superclass(); typeBinding.superInterfaces(); } catch (AbortCompilation e) { // classpath problem for this type: ignore + } finally { + this.lookupEnvironment.unitBeingCompleted = previousUnitBeingCompleted; } } } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/util/Util.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v retrieving revision 1.59 diff -u -r1.59 Util.java --- src/org/eclipse/jdt/core/tests/util/Util.java 22 Oct 2007 13:43:38 -0000 1.59 +++ src/org/eclipse/jdt/core/tests/util/Util.java 19 Dec 2007 16:40:40 -0000 @@ -311,6 +311,11 @@ output.close(); } } +public static void createClassFolder(String[] pathsAndContents, String folderPath, String compliance) throws IOException { + File classesDir = new File(folderPath); + flushDirectoryContent(classesDir); + compile(pathsAndContents, getCompileOptions(compliance), folderPath); +} public static void createJar(String[] pathsAndContents, Map options, String jarPath) throws IOException { String classesPath = getOutputDirectory() + File.separator + "classes"; File classesDir = new File(classesPath); @@ -319,19 +324,7 @@ zip(classesDir, jarPath); } public static void createJar(String[] pathsAndContents, String jarPath, String compliance) throws IOException { - Map options = new HashMap(); - options.put(CompilerOptions.OPTION_Compliance, compliance); - options.put(CompilerOptions.OPTION_Source, compliance); - options.put(CompilerOptions.OPTION_TargetPlatform, compliance); - // Ignore options with new defaults (since bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=76530) - options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_ReportTypeParameterHiding, CompilerOptions.IGNORE); - options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); - options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); - createJar(pathsAndContents, options, jarPath); + createJar(pathsAndContents, getCompileOptions(compliance), jarPath); } public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException { String sourcesPath = getOutputDirectory() + File.separator + "sources"; @@ -615,6 +608,21 @@ delete(files[i]); } } +private static Map getCompileOptions(String compliance) { + Map options = new HashMap(); + options.put(CompilerOptions.OPTION_Compliance, compliance); + options.put(CompilerOptions.OPTION_Source, compliance); + options.put(CompilerOptions.OPTION_TargetPlatform, compliance); + // Ignore options with new defaults (since bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=76530) + options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_ReportTypeParameterHiding, CompilerOptions.IGNORE); + options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); + options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); + return options; +} /** * Returns the next available port number on the local host. */ #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.78 diff -u -r1.78 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 12 Dec 2007 10:42:43 -0000 1.78 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 19 Dec 2007 16:40:43 -0000 @@ -1506,6 +1506,41 @@ "Sub types:\n", hierarchy); } +/* + * Ensures that a hierarchy on a binary type that extends a missing class with only binary types in the project + * is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213249 ) + */ +public void testMissingBinarySuperclass() throws Exception { + try { + IJavaProject project = createJavaProject("P", new String[0], "bin"); + addClassFolder(project, "lib", new String[] { + "p/X213249.java", + "package p;\n" + + "public class X213249 {\n" + + "}", + "p/Y213249.java", + "package p;\n" + + "public class Y213249 extends X213249 {\n" + + "}", + "p/Z213249.java", + "package p;\n" + + "public class Z213249 extends Y213249 {\n" + + "}", + }, "1.4"); + deleteFile("/P/lib/p/X213249.class"); + IType type = getClassFile("/P/lib/p/Z213249.class").getType(); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); + assertHierarchyEquals( + "Focus: Z213249 [in Z213249.class [in p [in lib [in P]]]]\n" + + "Super types:\n" + + " Y213249 [in Y213249.class [in p [in lib [in P]]]]\n" + + "Sub types:\n", + hierarchy); + } finally { + deleteProject("P"); + } +} /** * Ensures that a potential subtype that is not in the classpth is handle correctly. * (Regression test for PR #1G4GL9R) Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v retrieving revision 1.196 diff -u -r1.196 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 18 Dec 2007 16:32:55 -0000 1.196 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 19 Dec 2007 16:40:42 -0000 @@ -271,6 +271,24 @@ entries[length] = entry; project.setRawClasspath(entries, null); } + protected void addClassFolder(IJavaProject javaProject, String folderRelativePath, String[] pathAndContents, String compliance) throws CoreException, IOException { + IProject project = javaProject.getProject(); + String projectLocation = project.getLocation().toOSString(); + String folderPath = projectLocation + File.separator + folderRelativePath; + org.eclipse.jdt.core.tests.util.Util.createClassFolder(pathAndContents, folderPath, compliance); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + String projectPath = '/' + project.getName() + '/'; + addLibraryEntry( + javaProject, + new Path(projectPath + folderRelativePath), + null, + null, + null, + null, + true + ); + + } protected void addLibrary(String jarName, String sourceZipName, String[] pathAndContents, String compliance) throws CoreException, IOException { addLibrary(this.currentProject, jarName, sourceZipName, pathAndContents, null, null, compliance); }