Project: JDT
Bug 86967 [1.5][dom] NPE in BindingKeyResolver for multi-level parameterized type binding
Reported: 2005-03-02 02:59:56 | Status: verified fixed

ASTParser.createASTs(..) cannot recreate the return type binding of HashMap#entrySet(): public Set<Map.Entry<K,V>> entrySet() ... from its binding key: Ljava/util/Map$Entry<Ljava/util/Map<TK;TV;>;:TK;Ljava/util/Map<TK;TV;>;:TV;>; Steps to reproduce: - Have this source in an editor: import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; class A { void sets() { Map map= new HashMap(); map.put("key", new Integer(17)); Set entrySet= map.entrySet(); Iterator iter= entrySet.iterator(); Map.Entry entry= (Map.Entry) iter.next(); } } - run Refactor > Infer Generic Type Arguments..., press Preview The refactoring probably has another problem, but this bug makes it hard to debug. java.lang.NullPointerException at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getTypeBinding(BindingKeyResolver.java:324) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.consumeMemberType(BindingKeyResolver.java:141) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseInnerType(BindingKeyParser.java:531) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:435) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:419) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getCompilerBinding(BindingKeyResolver.java:317) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:684) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:441) at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:651) at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeEnvironment.createTypeBindings(TypeEnvironment.java:104) at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.rewriteConstraintVariable(InferTypeArgumentsRefactoring.java:329) at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.rewriteDeclarations(InferTypeArgumentsRefactoring.java:237) at org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.checkFinalConditions(InferTypeArgumentsRefactoring.java:178) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1702) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:111)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java