| Summary: | NullPointerException in creation of new class | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Matthias Hilbig <mhilbig> | ||||
| Component: | cdt-core | Assignee: | Sergey Prigogin <eclipse.sprigogin> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Doug Schaefer <cdtdoug> | ||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | eclipse.sprigogin, malaperle, toni.heimala, uwe_kindler | ||||
| Version: | 8.0 | ||||||
| Target Milestone: | 8.0.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Matthias Hilbig
It would be helpful to know what template changes are necessary to reproduce this NPE. Fixed in cdt_8_0 and master > 20110624. BTW, I'm still curious what template change triggered the NPE. Maybe its another setting I did, because the class creation still does not work
if I restore defaults in the file creation templates.
I only changed the file comment header to
/**
@file
@brief
@author ${user}
@date ${date}
@if NeverInclude
Copyright ZBH Center for Bioinformatics
University of Hamburg
Bundesstrasse 43, 20146 Hamburg, Germany
================================================================================
This module is part of the molecule software library Naomi,
developed at the Center for Bioinformatics Hamburg (ZBH).
It is not allowed to use, modify, copy or redistribute this software without
written approval of the ZBH. For further information contact
ZBH Center for Bioinformatics, University of Hamburg
Research Group for Computational Molecular Design
Voice: +49 (40) 42838 7350
Fax: +49 (40) 42838 7352
E-Mail: info@zbh.uni-hamburg.de
==============================================================================
@endif
*/
After updating to CDT 8.0 creating new classes no longer works. I also get NullPointerException but I don't know if it's related to the issue described here. Here is the stacktrace from .log: !ENTRY org.eclipse.cdt.ui 4 4 2011-06-27 12:18:17.762 !MESSAGE Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1029) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard.performFinish(NewElementWizard.java:107) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.performFinish(NewClassCreationWizard.java:70) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) 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.navigator.wizards.WizardShortcutAction.run(WizardShortcutAction.java:98) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) 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.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) 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:344) 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) Caused by: java.lang.NullPointerException at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.createClass(NewClassCodeGenerator.java:208) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2116) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2056) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.finishPage(NewClassCreationWizard.java:60) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:100) at org.eclipse.cdt.internal.core.model.BatchOperation.executeOperation(BatchOperation.java:36) at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:339) at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:602) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1234) at org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:84) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Root exception: java.lang.NullPointerException at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.createClass(NewClassCodeGenerator.java:208) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2116) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2056) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.finishPage(NewClassCreationWizard.java:60) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:100) at org.eclipse.cdt.internal.core.model.BatchOperation.executeOperation(BatchOperation.java:36) at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:339) at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:602) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1234) at org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:84) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) (In reply to comment #5) Does creation of new classes work after restoring default code templates? Created attachment 198891 [details]
Export of my code templates
I have the same problem here on a Windows 7 machine with CDT 8.0. The error only occures if I disable the method stubs for constructor and destructor. As soon as I have the method stub for either constructor or destructor enabled, the problem does not occur and the class is created properly. Here are my sessin data: eclipse.buildId=I20110613-1736 java.version=1.6.0_24 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE Framework arguments: -product org.eclipse.epp.package.cpp.product Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.cpp.product This is my stack trace from error log: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1029) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard.performFinish(NewElementWizard.java:107) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.performFinish(NewClassCreationWizard.java:70) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) 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.navigator.wizards.WizardShortcutAction.run(WizardShortcutAction.java:98) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) 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.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) 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:344) 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:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) Caused by: java.lang.NullPointerException at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.constructClassDefinition(NewClassCodeGenerator.java:471) at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.constructHeaderFileContent(NewClassCodeGenerator.java:348) at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.createClass(NewClassCodeGenerator.java:211) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2116) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2056) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.finishPage(NewClassCreationWizard.java:60) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:100) at org.eclipse.cdt.internal.core.model.BatchOperation.executeOperation(BatchOperation.java:36) at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:339) at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:602) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1234) at org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:84) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Root exception: java.lang.NullPointerException at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.constructClassDefinition(NewClassCodeGenerator.java:471) at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.constructHeaderFileContent(NewClassCodeGenerator.java:348) at org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.createClass(NewClassCodeGenerator.java:211) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2116) at org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage.createClass(NewClassCreationWizardPage.java:2056) at org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard.finishPage(NewClassCreationWizard.java:60) at org.eclipse.cdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:100) at org.eclipse.cdt.internal.core.model.BatchOperation.executeOperation(BatchOperation.java:36) at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:339) at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:602) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1234) at org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:84) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) (In reply to comment #6) > (In reply to comment #5) > Does creation of new classes work after restoring default code templates? No. :( Please try a recent build from https://hudson.eclipse.org/hudson/job/cdt-nightly/. If you can reproduce the problem with this build, please describe the reproduction steps. It wasn't the code templates, it's disabling of Constructor and Destructor creation. If I change the code templates and only enable Constructor it works. I'm getting the same stack as uwe_kindler@web.de when I disable constructor and destructor, all defaults. I can't reproduce it when I launch another Eclipse from Eclipse to debug it, even using the same workspace. And when I look at the code, I don't see how it can trigger a NPE StringBuilder code = new StringBuilder(); ... if (body != null) { code.append(body); // NPE?? ... (In reply to comment #12) Are you running the released 8.0? The NPE was fixed after it went out. (In reply to comment #13) > (In reply to comment #12) > Are you running the released 8.0? The NPE was fixed after it went out. Ah never mind, it turns out I had a feature patch applied and was using an older version of cdt.ui. |