View | Details | Raw Unified | Return to bug 352605
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-5 / +40 lines)
Lines 44-49 Link Here
44
import org.eclipse.jdt.internal.core.JavaElement;
44
import org.eclipse.jdt.internal.core.JavaElement;
45
import org.eclipse.jdt.internal.core.PackageFragment;
45
import org.eclipse.jdt.internal.core.PackageFragment;
46
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
46
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
47
import org.eclipse.objectteams.otdt.internal.core.compiler.control.Config;
47
import org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies;
48
import org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies;
48
import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.CallinCalloutBinding;
49
import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.CallinCalloutBinding;
49
import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.DependentTypeBinding;
50
import org.eclipse.objectteams.otdt.internal.core.compiler.lookup.DependentTypeBinding;
Lines 534-540 Link Here
534
		ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
535
		ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
535
		ReferenceBinding[] internalInterfaces = null;
536
		ReferenceBinding[] internalInterfaces = null;
536
		try {
537
		try {
538
//{ObjectTeams: protect with minimally configured Dependencies:
539
// see Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes
540
		  Config cfg = null;
541
		  if (!Dependencies.isSetup())
542
			cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true);
543
		  try {
544
// orig:
537
			internalInterfaces = referenceBinding.superInterfaces();
545
			internalInterfaces = referenceBinding.superInterfaces();
546
// :giro
547
		  } finally {
548
			if (cfg != null)
549
				Dependencies.release(this);
550
		  }
551
// SH}	
538
		} catch (RuntimeException e) {
552
		} catch (RuntimeException e) {
539
			/* in case a method cannot be resolvable due to missing jars on the classpath
553
			/* in case a method cannot be resolvable due to missing jars on the classpath
540
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
554
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
Lines 902-908 Link Here
902
		}
916
		}
903
		ReferenceBinding superclass = null;
917
		ReferenceBinding superclass = null;
904
		try {
918
		try {
919
//{ObjectTeams: protect with minimally configured Dependencies:
920
// see Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes
921
		  Config cfg = null;
922
		  if (!Dependencies.isSetup())
923
			cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true);
924
		  try {
925
// orig:
905
			superclass = ((ReferenceBinding)this.binding).superclass();
926
			superclass = ((ReferenceBinding)this.binding).superclass();
927
// :giro
928
		  } finally {
929
			if (cfg != null)
930
				Dependencies.release(this);
931
		  }
932
// SH}
906
		} catch (RuntimeException e) {
933
		} catch (RuntimeException e) {
907
			/* in case a method cannot be resolvable due to missing jars on the classpath
934
			/* in case a method cannot be resolvable due to missing jars on the classpath
908
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
935
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
Lines 1294-1304 Link Here
1294
	    if (! this.binding.isRole())
1321
	    if (! this.binding.isRole())
1295
			return null;
1322
			return null;
1296
	    ReferenceBinding roleBinding = (ReferenceBinding) this.binding;
1323
	    ReferenceBinding roleBinding = (ReferenceBinding) this.binding;
1297
	    ReferenceBinding baseclass = roleBinding.baseclass();
1324
	    Config cfg = null;
1298
	    if (baseclass == null) {
1325
	    if (!Dependencies.isSetup())
1299
			return null;
1326
	    	cfg = Dependencies.setup(this, null, this.resolver.lookupEnvironment(), false, false, false, false, false, true);
1300
		}
1327
	    try {
1301
	    return this.resolver.getTypeBinding(baseclass);
1328
		    ReferenceBinding baseclass = roleBinding.baseclass();
1329
		    if (baseclass == null) {
1330
				return null;
1331
			}
1332
		    return this.resolver.getTypeBinding(baseclass);
1333
	    } finally {
1334
	    	if (cfg != null)
1335
	    		Dependencies.release(this);
1336
	    }
1302
	}
1337
	}
1303
//	ira+SH}
1338
//	ira+SH}
1304
1339
(-)src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java (-2 / +29 lines)
Lines 22-40 Link Here
22
22
23
import junit.framework.Test;
23
import junit.framework.Test;
24
24
25
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.NullProgressMonitor;
26
import org.eclipse.core.runtime.NullProgressMonitor;
26
import org.eclipse.jdt.core.ICompilationUnit;
27
import org.eclipse.jdt.core.ICompilationUnit;
27
import org.eclipse.jdt.core.dom.AST;
28
import org.eclipse.jdt.core.dom.AST;
28
import org.eclipse.jdt.core.dom.ASTNode;
29
import org.eclipse.jdt.core.dom.ASTNode;
29
import org.eclipse.jdt.core.dom.ASTParser;
30
import org.eclipse.jdt.core.dom.ASTParser;
30
import org.eclipse.jdt.core.dom.CompilationUnit;
31
import org.eclipse.jdt.core.dom.CompilationUnit;
31
import org.eclipse.jdt.core.dom.Expression;
32
import org.eclipse.jdt.core.dom.FieldDeclaration;
32
import org.eclipse.jdt.core.dom.ITypeBinding;
33
import org.eclipse.jdt.core.dom.ITypeBinding;
33
import org.eclipse.jdt.core.dom.LiftingType;
34
import org.eclipse.jdt.core.dom.LiftingType;
34
import org.eclipse.jdt.core.dom.MethodDeclaration;
35
import org.eclipse.jdt.core.dom.MethodDeclaration;
35
import org.eclipse.jdt.core.dom.Name;
36
import org.eclipse.jdt.core.dom.Name;
36
import org.eclipse.jdt.core.dom.RoleTypeDeclaration;
37
import org.eclipse.jdt.core.dom.RoleTypeDeclaration;
37
import org.eclipse.jdt.core.dom.SimpleType;
38
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
38
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
39
import org.eclipse.jdt.core.dom.Type;
39
import org.eclipse.jdt.core.dom.Type;
40
import org.eclipse.jdt.core.dom.TypeDeclaration;
40
import org.eclipse.jdt.core.dom.TypeDeclaration;
Lines 174-177 Link Here
174
		typeBinding = typeName.resolveTypeBinding();
174
		typeBinding = typeName.resolveTypeBinding();
175
    	assertEquals("Wrong type binding for name", "MyClass", typeBinding.getName());
175
    	assertEquals("Wrong type binding for name", "MyClass", typeBinding.getName());
176
    }
176
    }
177
178
	// Bug 352605 - Eclipse is reporting "Could not retrieve superclass" every few minutes
179
    public void testBug352605() throws CoreException {
180
		ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
181
		parser.setProject(getJavaProject(TEST_PROJECT));
182
        parser.setResolveBindings(true);
183
        parser.setUnitName("C");
184
		parser.setSource(("public class C {\n" +
185
				"public bug352605.Sub f;\n" +
186
				"}\n").toCharArray());
187
		
188
		ASTNode root = parser.createAST( new NullProgressMonitor() );
189
		CompilationUnit compUnit = (CompilationUnit) root;
190
        
191
		TypeDeclaration type = (TypeDeclaration) compUnit.types().get(0);
192
		FieldDeclaration field = (FieldDeclaration) type.bodyDeclarations().get(0);
193
		Type fieldType = field.getType();
194
		ITypeBinding typeBinding = fieldType.resolveBinding();
195
		assertNotNull("Field type binding should be non-null", typeBinding);
196
		assertFalse("typeBinding should be from class file", typeBinding.isFromSource());
197
		typeBinding = typeBinding.getSuperclass();
198
		assertNotNull("super class should be non-null", typeBinding);
199
		assertTrue("typeBinding should be from source", typeBinding.isFromSource());
200
		typeBinding = typeBinding.getSuperclass();
201
		assertNotNull("2nd super class should be non-null", typeBinding);
202
		assertTrue("2nd super class should be Object", typeBinding.getQualifiedName().equals("java.lang.Object"));
203
    }
177
}
204
}
(-)workspace/DOM_AST/src/bug352605/Super.java (+4 lines)
Line 0 Link Here
1
package bug352605;
2
3
public class Super {
4
}

Return to bug 352605