### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java =================================================================== --- dom/org/eclipse/jdt/core/dom/TypeBinding.java (revision 1774) +++ dom/org/eclipse/jdt/core/dom/TypeBinding.java (working copy) @@ -44,6 +44,7 @@ import org.eclipse.jdt.internal.core.JavaElement; import org.eclipse.jdt.internal.core.PackageFragment; import org.eclipse.objectteams.otdt.core.compiler.IOTConstants; +import org.eclipse.objectteams.otdt.internal.core.compiler.control.Config; import org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies; import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.CallinCalloutBinding; import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.DependentTypeBinding; @@ -534,7 +535,20 @@ ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; ReferenceBinding[] internalInterfaces = null; try { +//{ObjectTeams: protect with minimally configured Dependencies: +// see Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes + Config cfg = null; + if (!Dependencies.isSetup()) + cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true); + try { +// orig: internalInterfaces = referenceBinding.superInterfaces(); +// :giro + } finally { + if (cfg != null) + Dependencies.release(this); + } +// SH} } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 @@ -902,7 +916,20 @@ } ReferenceBinding superclass = null; try { +//{ObjectTeams: protect with minimally configured Dependencies: +// see Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes + Config cfg = null; + if (!Dependencies.isSetup()) + cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true); + try { +// orig: superclass = ((ReferenceBinding)this.binding).superclass(); +// :giro + } finally { + if (cfg != null) + Dependencies.release(this); + } +// SH} } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 @@ -1294,11 +1321,19 @@ if (! this.binding.isRole()) return null; ReferenceBinding roleBinding = (ReferenceBinding) this.binding; - ReferenceBinding baseclass = roleBinding.baseclass(); - if (baseclass == null) { - return null; - } - return this.resolver.getTypeBinding(baseclass); + Config cfg = null; + if (!Dependencies.isSetup()) + cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true); + try { + ReferenceBinding baseclass = roleBinding.baseclass(); + if (baseclass == null) { + return null; + } + return this.resolver.getTypeBinding(baseclass); + } finally { + if (cfg != null) + Dependencies.release(this); + } } // ira+SH} #P org.eclipse.objectteams.otdt.ui.tests.dom Index: src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java =================================================================== --- src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java (revision 1146) +++ src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java (working copy) @@ -22,19 +22,19 @@ import junit.framework.Test; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; +import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.LiftingType; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.RoleTypeDeclaration; -import org.eclipse.jdt.core.dom.SimpleType; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.Type; import org.eclipse.jdt.core.dom.TypeDeclaration; @@ -174,4 +174,31 @@ typeBinding = typeName.resolveTypeBinding(); assertEquals("Wrong type binding for name", "MyClass", typeBinding.getName()); } + + // Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes + public void testBug352605() throws CoreException { + ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL); + parser.setProject(getJavaProject(TEST_PROJECT)); + parser.setResolveBindings(true); + parser.setUnitName("C"); + parser.setSource(("public class C {\n" + + "public bug352605.Sub f;\n" + + "}\n").toCharArray()); + + ASTNode root = parser.createAST( new NullProgressMonitor() ); + CompilationUnit compUnit = (CompilationUnit) root; + + TypeDeclaration type = (TypeDeclaration) compUnit.types().get(0); + FieldDeclaration field = (FieldDeclaration) type.bodyDeclarations().get(0); + Type fieldType = field.getType(); + ITypeBinding typeBinding = fieldType.resolveBinding(); + assertNotNull("Field type binding should be non-null", typeBinding); + assertFalse("typeBinding should be from class file", typeBinding.isFromSource()); + typeBinding = typeBinding.getSuperclass(); + assertNotNull("super class should be non-null", typeBinding); + assertTrue("typeBinding should be from source", typeBinding.isFromSource()); + typeBinding = typeBinding.getSuperclass(); + assertNotNull("2nd super class should be non-null", typeBinding); + assertTrue("2nd super class should be Object", typeBinding.getQualifiedName().equals("java.lang.Object")); + } } Index: workspace/DOM_AST/src/bug352605/Super.java =================================================================== --- workspace/DOM_AST/src/bug352605/Super.java (revision 0) +++ workspace/DOM_AST/src/bug352605/Super.java (revision 0) @@ -0,0 +1,4 @@ +package bug352605; + +public class Super { +}