Community
Participate
Working Groups
When generating a New Class as a subclass of an abstract class, a null pointer exception is thrown (at least every other time). Stack trace from log below. I will attach the class. 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:758) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.performFinish (NewElementWizard.java:96) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard.performFinish (NewClassCreationWizard.java:66) at org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java:608) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:321) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction.run (AbstractOpenWizardAction.java:158) at org.eclipse.jdt.internal.ui.wizards.NewTypeDropDownAction.run (NewTypeDropDownAction.java:75) at org.eclipse.jdt.internal.ui.wizards.NewTypeDropDownAction.run (NewTypeDropDownAction.java:106) at org.eclipse.ui.internal.PluginAction.runWithEvent (PluginAction.java:251) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:207) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.core.SourceType.equalsDOMNode (SourceType.java:127) at org.eclipse.jdt.internal.core.JavaElement.followPath (JavaElement.java:217) at org.eclipse.jdt.internal.core.JavaElement.findNode (JavaElement.java:207) at org.eclipse.jdt.internal.core.CreateTypeMemberOperation.generateNewCompilationU nitDOM(CreateTypeMemberOperation.java:65) at org.eclipse.jdt.internal.core.CreateElementInCUOperation.executeOperation (CreateElementInCUOperation.java:133) at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:365) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:684) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1595) at org.eclipse.jdt.internal.core.JavaElement.runOperation (JavaElement.java:543) at org.eclipse.jdt.internal.core.SourceType.createMethod (SourceType.java:109) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createInheritedMethods (NewTypeWizardPage.java:1715) at org.eclipse.jdt.ui.wizards.NewClassWizardPage.createTypeMembers (NewClassWizardPage.java:242) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType (NewTypeWizardPage.java:1406) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard.finishPage (NewClassCreationWizard.java:52) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run (NewElementWizard.java:89) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:365) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:684) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1595) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:2711) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) ... 38 more
Created attachment 4493 [details] Visitor.java This is the abstract superclass. I have performed this operation prior to 2.1 final without any problems.
Martin, can you please comment.
could not reproduce. Bob, do you have an other reproducible case? The attached code refers to lots of other types from your project. I tried to simulate such a project but couldn't reproduce the problem. Please also have a look at the 'new file template'. Do you have something special in there (then the bug is that we don't prevent you from doing that). From the stacktrace, JCore has the problem: equalsDomNode does gets null as argument. followPath uses the method with dom.getFirstChild() which seems to be null. Moving to JCore
I will investigate.
I could not reproduce with your test case. Do you have any error prior to save the subclass? Did you get the error over and over again? If it is repeatable, could you please provide us with steps to reproduce? Thanks.
For this particular example, it happens about half the time. Usually the pattern is, I try it, it fails. I delete the (empty) generated file and try it again. It succeeds. Nothing special about it. The new class is not in the same package as the Elem, Exp, Factory classes, is in the same package as all others. To bring up dialog I right-click on a file in the package explorer that is already in the desired package, New > Java Class. Dialog comes up. Type the class name. Below hit Browse button. Dialog comes up. Type Visitor. Click OK. Click Finish. I don't feel right about supplying entire package, esp. since there's no guarantee that would enable you to reproduce it. Since it doesn't happen every time for me, I hope the fact it doesn't happen anytime for you won't prevent someone from following up on the stack trace I sent.
I already looked at the stack trace and I don't see why the node is suddendly null. I will try your test case again.
Could not reproduce after about twenty tries. Do you use specific settings? I know something is wrong, but I still need to find a reproducable test case to fix it.
Deja vu. Seems to me I filed an earlier bug involving visitors that couldn't be reproduced there. Even when I tried to boil it down with the usual binary chop I couldn't get a small, consistently failing case. Are multiple threads involved in this refactoring? Visitors are recursively self-referential. That is, each class overrides a visit(visitor) method to call a visitor.visitXXX(XXX item) method, where XXX is the class. But this is just the Visitor pattern. Again, the fact that it doesn't fail consistently, even for me, suggests some kind of race.
Moving to JDT/UI for comment. Could you please comment 9 from Bob Foster? Move it back to JDT/Core when done. I tried unsuccessfully to reproduce the problem. It looks like the compilation unit changed during the iteration of the path to a JDOM element.
There are no other threads involved in the creation of the class, but of course the reconciler thread could interfere. Olivier, what about that?
Bob, could it be possible that you had syntax error in your code?
The first time, maybe. But when I tried to reproduce it again a few days later and saw it about 50% of the time, I don't think so. But if you have a bug like that, it would be good to fix it. ;-}
Did you get it lately using 3.0 integration build?
Closing as WORKSFORME. Please reopen if you get it again.