Community
Participate
Working Groups
Build ID: I20080606-1637 Steps To Reproduce: this happens in our codebase, when invoking content assist after ModelUpdateRunnable, before the < in the following snippet: public void testAddEntryMultiple() { getViewModel().updateModel(ModelUpdateRunnable<V, Exception>) } However, I wasn't able to find a standalone snippet that causes the same problem. Here are the definitions of the update method and the ModelUpdateRunnable interface: public <V, E extends Exception> V updateModel(ModelUpdateRunnable<V, E> code) throws E; public interface ModelUpdateRunnable<V, E extends Exception> { public V run(IOutlineModelUpdater updateAccessor) throws E; } More information: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:1392) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods(SourceTypeBinding.java:1123) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:595) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.buildAnonymousTypeBinding(ClassScope.java:68) at org.eclipse.jdt.internal.compiler.lookup.BlockScope.addAnonymousType(BlockScope.java:69) at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.resolveType(QualifiedAllocationExpression.java:356) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:344) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:882) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:233) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:444) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:191) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:403) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1096) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1184) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:535) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:743) at org.eclipse.jdt.core.dom.CompilationUnitResolver.process(CompilationUnitResolver.java:308) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.consumeTopLevelType(BindingKeyResolver.java:378) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:584) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:567) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseTypeArgument(BindingKeyParser.java:853) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseParameterizedType(BindingKeyParser.java:809) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:598) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse(BindingKeyParser.java:567) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getCompilerBinding(BindingKeyResolver.java:525) at org.eclipse.jdt.core.dom.CompilationUnitResolver.reportBinding(CompilationUnitResolver.java:780) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:729) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:474) at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:736) at org.eclipse.jdt.internal.ui.text.java.LazyGenericTypeProposal.getExpectedType(LazyGenericTypeProposal.java:603) at org.eclipse.jdt.internal.ui.text.java.LazyGenericTypeProposal.computeTypeArgumentProposals(LazyGenericTypeProposal.java:298) at org.eclipse.jdt.internal.ui.text.java.LazyGenericTypeProposal.computeContextInformation(LazyGenericTypeProposal.java:773) at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getContextInformation(LazyJavaCompletionProposal.java:201) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:937) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$21(CompletionProposalPopup.java:887) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:492) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:479) at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1664) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:177) at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:471) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:822) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:511) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1184) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:341) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2370) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
I can not reproduce the NPE without the complete test case. The problem occurs when th e binding key of the expected type is decoded. Michael - Could you give this binding key ? To see the binding key you can put a breakpoint in CompletionContext#getExpectedTypesKeys() and debug an eclipse instance. You can also start eclipse with -debug and enable the trace of completion in the .options file. org.eclipse.jdt.core/debug=true org.eclipse.jdt.core/debug/completion=true It will display in the console something which look like: COMPLETION - Completion node : <CompleteOnName:ModelUpdateRunnable> COMPLETION - Parent Node : getViewModel().updateModel(<CompleteOnName:ModelUpdateRunnable>) completion offset=178 completion range=[159, 177] completion token="ModelUpdateRunnable" expectedTypesSignatures={Lp.ModelUpdateRunnable<TV;TE;>;} expectedTypesKeys={Lp/ModelUpdateRunnable<Lp/ViewModel;:0TV;Lp/ViewModel;:0TE;>;} The binding key is the value after 'expectedTypesKeys='.
expectedTypesKeys: char[1][327] Lcom/ibm/team/apt/internal/ide/ui/common/model/ModelUpdateRunnable<Lcom/ibm/team/apt/internal/ide/ui/common/model/OutlineModel<Lcom/ibm/team/apt/internal/ide/ui/common/model/SimpleElement;>;:58TV;Lcom/ibm/team/apt/internal/ide/ui/common/model/OutlineModel<Lcom/ibm/team/apt/internal/ide/ui/common/model/SimpleElement;>;:58TE;>; expectedTypesSignatures char[1][75] Lcom.ibm.team.apt.internal.ide.ui.common.model.ModelUpdateRunnable<TV;TE;>; extendedContext.assistNode <CompleteOnName:ModelUpdateRunnable> extendedContext.assistScope --- Method Scope --- locals: startIndex = 0 isConstructorCall = false initializedField = null lastVisibleFieldID = -1 referenceContext = public void testRemoveEntry() { getViewModel().updateModel(<CompleteOnName:ModelUpdateRunnable>); }
Adopting since the problem is in the BindingKeyResolver.
To reproduce: 1. New workspace on a JDK1.5.0 2. Paste the following compilation units in Package Explorer: =================================================== public class A { public void foo(C c) { c.bar(B //|<---Ctrl+Space after B } } class B<V, E> { } =================================================== public class C { public <V, E> void bar(B<V, E> code) { new D(null) {}; } } class D { D(Object o) {} } =================================================== 3. Press Ctrl+Space where indicated 4. Press Enter to accept the first proposal Observe: You get the NPE reported in comment 0 in the .log (or Error view if opened)
Same problem exists in 3.3.x
Created attachment 104652 [details] Proposed fix and regression test
Since this is an NPE and there is no workaround, I'm backporting this fix to 3.4.1
Fix and test released for 3.4.1
Fix and test released for 3.5M1
Verified for 3.5M1 using I20080805-1307
Verified for 3.4.1 using M20080827-2000.