Project: JDT
Bug 15247 Class/Interface wizard fails if a ${cursor} variable is in the type or filecomment template
Reported: 2002-05-03 19:01:12 | Status: resolved fixed

Upon using the New Class or New Interface wizard, if typecomment or filecomment is enabled at that template has a ${cursor} variable in it, the wizard fails with this exception: !ENTRY org.eclipse.jdt.ui 4 1 Fri May 03 16:58:04 MDT 2002 !MESSAGE Internal Error !STACK Java Model Exception: Java Model Status [Invalid contents specified.] at org.eclipse.jdt.internal.core.JavaModelOperation.execute(JavaModelOperation.java:270) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:476) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1361) at org.eclipse.jdt.internal.core.JavaModelManager.runOperation(JavaModelManager.java:1281) at org.eclipse.jdt.internal.core.JavaElement.runOperation(JavaElement.java:552) at org.eclipse.jdt.internal.core.CompilationUnit.createType(CompilationUnit.java:169) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType(NewTypeWizardPage.java:1187) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage$1.run(NewTypeWizardPage.java:1416) at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:39) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:64) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1361) at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:78) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:296) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:720) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.finishPage(NewElementWizard.java:66) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard.performFinish(NewClassCreationWizard.java:42) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:577) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:312) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:379) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:85) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1412) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1208) at org.eclipse.jface.window.Window.runEventLoop(Window.java:538) at org.eclipse.jface.window.Window.open(Window.java:525) at org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction.run(AbstractOpenWizardAction.java:147) at org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction.run(AbstractOpenWizardAction.java:165) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:202) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:165) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1412) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1208) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:883) at org.eclipse.ui.internal.Workbench.run(Workbench.java:866) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:733) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:349) 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:162) at org.eclipse.core.launcher.Main.run(Main.java:588) at org.eclipse.core.launcher.Main.main(Main.java:437) The underlying file is created, but it contains only the package declaration. Removing the ${cursor} var fixes this. While having that var in these templates doesn't make much sense, it still shouldn't cause a problem like this. This is with the 0502 integration build.

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaFormatter.java