Community
Participate
Working Groups
Build 200404201300 When I use the New Class wizard to create a class, the following exception occurs on Finish. The new .java file is created with no contents. java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:313) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:753) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.performFinish(NewElementWizard.java: 110) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard. performFinish(NewClassCreationWizard.java:62) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:613) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:330) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:413) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:939) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1995) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1768) at org.eclipse.jface.window.Window.runEventLoop(Window.java:670) at org.eclipse.jface.window.Window.open(Window.java:650) at org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction.run(AbstractOpenWizardAction. java:158) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem. handleWidgetSelection(ActionContributionItem.java:550) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:502) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java: 435) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:939) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1995) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1768) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1437) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1408) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:244) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:280) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) 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:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:267) at org.eclipse.core.launcher.Main.run(Main.java:699) at org.eclipse.core.launcher.Main.main(Main.java:683) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions. set(DefaultCodeFormatterOptions.java:413) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions. <init>(DefaultCodeFormatterOptions.java:228) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.<init>(DefaultCodeFormatter.java:49) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.<init>(DefaultCodeFormatter.java:62) at org.eclipse.jdt.core.ToolFactory.createCodeFormatter(ToolFactory.java:96) at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.format2(CodeFormatterUtil.java:148) at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.format2(CodeFormatterUtil.java:152) at org.eclipse.jdt.internal.corext.codemanipulation.ImportsStructure. useSpaceBetweenGroups(ImportsStructure.java:754) at org.eclipse.jdt.internal.corext.codemanipulation.ImportsStructure. getReplaceString(ImportsStructure.java:667) at org.eclipse.jdt.internal.corext.codemanipulation.ImportsStructure.create(ImportsStructure. java:576) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage$ImportsManager. create(NewTypeWizardPage.java:146) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType(NewTypeWizardPage.java:1469) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard. finishPage(NewClassCreationWizard.java:49) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:103) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1640) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3262) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter. run(WorkbenchRunnableAdapter.java:61) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302) ... 38 more
NPE happens in org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions
What VM are you using? The line on which you get the NPE is: final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION); So this means that settings is null. But in the stack trace, settings cannot be null. We have this call: if (settings == null) return; set(settings);
Without further details from you, I will close as WORKSFORME.
I was on JDK 1.4.2.
From Sun or IBM? If IBM, using J9 or not?
Sorry. I actually lied. I *thought* I was using Sun JDK 1.4.2, but I was actually using Sun JDK 1.4. 1. I haven't seen this again since it first happened so I'm reducing the severity. Are there any opportunities for multi-threaded timing problems in this area? I didn't fake this stack trace, I swear. :-)
I simply don't see how it is possible to get this stack trace looking at the code. If settings is null, the line (that causes the NPE) should never run.
That's why I asked about a timing problem. Can "settings" get nulled out in another thread after the null check?
settings is not an instance variable. It is a parameter of a method. So the problem should be local to that method. I don't see how settings can be null.
Close as WORKSFORME. Please reopen if you have steps to reproduce.