Community
Participate
Working Groups
When trying to export keys, I get: java.lang.NullPointerException at org.eclipse.ui.internal.keys.model.KeyController$7.run(KeyController.java:524) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.ui.internal.keys.model.KeyController.exportCSV(KeyController.java:542) at org.eclipse.ui.internal.keys.NewKeysPreferencePage$2.widgetSelected(NewKeysPreferencePage.java:604) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ui.internal.handlers.ShowPreferencePageHandler.execute(ShowPreferencePageHandler.java:57) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:281) 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.wmKeyDown(Widget.java:1653) at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:4122) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3818) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541) 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(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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)
What build are you trying this on? Eclipse Classic? Eclipse for Java Developers? Are you using any third-party plug-ins? This seems to work fine for me. From the stack trace, it seems that one of the BindingElements being exported do not have a context for whatever reason.
I use Eclipse Classic with lots of plugins. But a missing context should not cause an NPE, should it?
(In reply to comment #2) > I use Eclipse Classic with lots of plugins. Can you try to reproduce this with Eclipse Classic 3.4.0 only? > But a missing context should not cause an NPE, should it? Well, the code on that line is something like be.getContext().getName(), so yes, that's going to cause an NPE.
(In reply to comment #3) > Can you try to reproduce this with Eclipse Classic 3.4.0 only? I can, but most probably, it will work then. And what then? ;) > Well, the code on that line is something like be.getContext().getName(), so > yes, that's going to cause an NPE. Why not context = be.getContext(); if (context != null) { name = context.getName(); ...
(In reply to comment #4) > > Well, the code on that line is something like be.getContext().getName(), so > > yes, that's going to cause an NPE. > > Why not > > context = be.getContext(); > if (context != null) { > name = context.getName(); > ... Well, you asked why it's throwing an NPE so I explained why. ;) Why there isn't a null guard there is a separate question. Perhaps the assumption is that any BindingElement that is going to be exported should never return a null context and as such there is no null guard, I don't know.
One never should assume too much. ;)
(In reply to comment #4) > (In reply to comment #3) > > Can you try to reproduce this with Eclipse Classic 3.4.0 only? > > I can, but most probably, it will work then. And what then? ;) I suppose then we can figure one of the keybindings may not be defined properly in one of your plug-ins and that the ones defined by the Eclipse Classic build are okay. In this case, better warnings needs to be provided when scanning contributed keybindings so that the plug-in's developer can catch the error before rolling out a plug-in that contributes keybindings with no context. Alternatively, maybe it was a user-defined keybinding that failed. So that must mean the model code isn't handling model changes properly or something. Or it could be something else. Who knows, the less variables there are, the easier it'll be able to pinpoint the exact error. :) (In reply to comment #6) > One never should assume too much. ;) While I see where you're coming from, I don't know how often people write code like... myObj.getX().getY().doZ(); ...as... Assert.isNotNull(myObj); Assert.isNotNull(myObj.getX()); Assert.isNotNull(myObj.getX().getY()); Assert.isNotNull(myObj.getX().getY().doZ()); ...or... if (myObj != null && myObj.getX() != null && myObj.getX().getY() != null) { myObj.getX().getY().doZ(); } Of course, most people probably model their classes a little better, but you get the idea. In any case, if it is assumed that the context should never be null (I don't know personally since I didn't write this code) but the context is null, then the code analyzing the model must be off somewhere since I'd imagine that we should technically never export any keybindings without a context. So while adding a null guard would prevent this NPE, perhaps the null guard should be somewhere else?
The same error happens here with plain Eclipse Classic, but still with my customized bindings. (In reply to comment #7) > While I see where you're coming from, I don't know how often people write code > like... > > myObj.getX().getY().doZ(); I come from an Eiffel background, so I am very sensitive regarding such issues. ;)
Could it be that this happens if there are key bindings of plugins that are no longer installed? As a side question: How does one get rid of such orphaned bindings?
This is indeed the case. I managed to remove all undefined commands and now, the NPE is gone. So, the null guard has to be in the export code.
Updated as per http://wiki.eclipse.org/Platform_UI/Bug_Triage PW
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
This bug was marked as stalebug a while ago. Marking as wontfix. If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard tag.