Community
Participate
Working Groups
I have some user assistance tools including Dynamic Help implemented that have worked satisfactorily for several releases of Eclipse. Recently while developing/testing in 3.7M4 I started getting a NPE when I do Help>Dynamic Help Any idea why? Sometimes I get the error when I just click in the editor window w/o selecting Help > Dynamic Help !ENTRY org.eclipse.ui.workbench 4 0 2011-01-13 14:31:20.648 !MESSAGE An unexpected exception was thrown. !STACK 0 java.lang.NullPointerException at org.eclipse.help.ui.internal.util.EscapeUtils.escapeSpecialChars(EscapeUtils.java:71) at org.eclipse.help.ui.internal.util.EscapeUtils.escapeSpecialChars(EscapeUtils.java:28) at org.eclipse.help.ui.internal.views.ContextHelpPart.formatHelpContext(ContextHelpPart.java:611) at org.eclipse.help.ui.internal.views.ContextHelpPart.handleActivation(ContextHelpPart.java:318) at org.eclipse.help.ui.internal.views.RelatedTopicsPart.handleActivation(RelatedTopicsPart.java:131) at org.eclipse.help.ui.internal.views.ReusableHelpPart.showDynamicHelp(ReusableHelpPart.java:1017) at org.eclipse.help.ui.internal.views.HelpView.showDynamicHelp(HelpView.java:393) at org.eclipse.help.ui.internal.DefaultHelpUI.displayDynamicHelp(DefaultHelpUI.java:156) at org.eclipse.ui.internal.help.WorkbenchHelpSystem.displayDynamicHelp(WorkbenchHelpSystem.java:869) at org.eclipse.ui.internal.handlers.DynamicHelpHandler$1.run(DynamicHelpHandler.java:29) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.handlers.DynamicHelpHandler.execute(DynamicHelpHandler.java:27) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293) 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.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241) at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3955) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1435) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1443) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1255) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3801) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3454) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 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:369) 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:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) My classes implement org.eclipse.cdt.ui.ICHelpBook but I don't see where CDT classes figure into the stack trace above. Any ideas? Using Eclipse 3.7M4 Version: 3.7.0 Build id: I20101208-1300 with CDT 8.0.0.201101070803 I did just add a large number of context help strings partially machine-generated so it seems like perhaps I could have a special character that needs escaping somewhere, but I still get the problem if I run with only the classes that haven't been changed or newly added for a long time. (Without the new stuff) To replicate: Launch a workbench with PTP's org.eclipse.ptp.pldt.mpi.core plugin enabled (this is the older one that hasn't changed. I'm running from a dev. wb and launching a rt workbench) Make a CDT project, e.g. "New C Project" and use the "Hello World ANSI C project" Insert an MPI call e.g. MPI_Init(): and #include <mpi.h> click on MPI_Init and select Help>Dynamic Help. It should bring up the Help view. NPE error occurs in popup with no additional info. Error View or error log gives full stack trace above. I can't get it to fail without including at least some of my code in the runtime workbench, but don't see how it's related from the stack trace above. Any ideas? Thanks.
Looking at the stack trace ContextHelpPart.formatHelpContext(ContextHelpPart.java:611) is sbuf.append(EscapeUtils.escapeSpecialChars(link.getLabel())); the code is creating the hyperlinks to the related topics. For some reason the label for this related topic is null. I can eliminate the NPE easily enough but there is still something going wrong to cause the label to be null. I tried omitting the label attribute in the contexts.xml file but that did not reproduce the problem. If the application is using a context provider that could explain why the label is null. It sounds as though you are in an editor when you select context help, is that true. One possibility is that the CDT editor has a context provider and in this case the context is returning a null label. The help system should probably detect this situation and prevent the NPE, which is easy enough to do but it seems that would not completely fix the underlying problem of a context with null label being created.
Targeting Eclipse 3.7 to eliminate the NPE.
Yes when I imported some eclipse source I could tell that the label was null. I couldn't figure out why. Now I realize that a line of my code setting the label somehow got accidentally erased. Sorry about that. Mea culpa. But you're right, if the implementor doesn't supply it, perhaps you should fail a bit more gracefully, perhaps substituting "help label not supplied" or something so there is something to click on in the help view and it should be immediately apparent My apologies, but it was fun digging.
Created attachment 186790 [details] Patch This patch suppresses the NPE, instead the links still show but the description is "null". I had thought of not displaying the link if the label is null but that would mean the error could go undetected, this way the developer should be able to figure out what is happening and fix it.
Patch committed to HEAD, Fixed
+1 :-)