NullPointerExeption in "Open Type Hierarchy"
When attempting to open the type hierarchy for
scala.tools.refactoring.common.PimpedTrees
I getjava.lang.NullPointerException
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildMethods(ClassScope.java:324)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildFieldsAndMethods(ClassScope.java:180)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildFieldsAndMethods(ClassScope.java:191)
at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:84)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:295)
at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:166)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:178)
at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:201)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(Scope.java:2981)
at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.getTypeBinding(QualifiedTypeReference.java:97)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:472)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:571)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:567)
at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:541)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1292)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperInterfaces(ClassScope.java:1038)
at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:1096)
at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:323)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:292)
at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:166)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:178)
at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:201)
at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:468)
at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.checkAndSetImports(CompilationUnitScope.java:213)
at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:311)
at org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:816)
at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.buildForProject(IndexBasedHierarchyBuilder.java:227)
at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.buildFromPotentialSubtypes(IndexBasedHierarchyBuilder.java:307)
at org.eclipse.jdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.build(IndexBasedHierarchyBuilder.java:132)
at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:301)
at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1268)
at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:729)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:789)
at org.eclipse.jdt.internal.core.SourceType.newTypeHierarchy(SourceType.java:832)
at org.eclipse.jdt.internal.core.SourceType.newTypeHierarchy(SourceType.java:790)
at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.createTypeHierarchy(TypeHierarchyLifeCycle.java:299)
at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.doHierarchyRefresh(TypeHierarchyLifeCycle.java:330)
at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle.doHierarchyRefreshBackground(TypeHierarchyLifeCycle.java:271)
at org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle$2.run(TypeHierarchyLifeCycle.java:224)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Leave a comment
The problem appears in
of
// iterate the method declarations to create the bindings
AbstractMethodDeclaration[] methods = this.referenceContext.methods;
int size = methods == null ? 0 : methods.length;
// look for <clinit> method
int clinitIndex = -1;
for (int i = 0; i < size; i++) {
if (methods[i].isClinit()) { //<-- NP is thrown here
clinitIndex = i;
break;
}
}
of
org.eclipse.jdt.internal.compiler.lookup.ClassScope
because methods
, which looks like [public scala.tools.nsc.interactive.Global global() {}, null]
contains null
as last element. Unfortunately I don't know yet how null
ended up there, as this array seems to be accessed from different locations.
The offending array is set in
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceType, CompilationResult)
, as can be seen by setting a conditional breakpoint withif (type.methods.length < 1) {
return false;
} else {
int lastInd = type.methods.length - 1;
return type.methods[lastInd] == null;
}
on org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter:598
.
on 2015-06-05 05:20 *
By Iulian Dragos
Mathias, I think that the JDT version of type hierarchy is a lost cause. The assumptions it makes about code being Java are too strict. Have you tried scala-search? It has a Type Hierarchy feature and it should be much easier to fix, if there are bugs.
Thank you very much for clarifying; actually I was thinking that I used scala-search, but in fact I was using JDT. If I right click on a type, I have three possibilities to open the type hierarchy (see below):
Two of them are severely broken (the red ones), and one (the green one) might actually work. What about removing the broken options altogether, before anyone waists time debugging them again?
Two of them are severely broken (the red ones), and one (the green one) might actually work. What about removing the broken options altogether, before anyone waists time debugging them again?
Remove broken "Open Type Hierarchy" menu items
Fixes #1002478
Branch: master
Commit: scala-ide:5f071a19b6
Fixes #1002478
Branch: master
Commit: scala-ide:5f071a19b6