Bug 36200 - New Class throws exception
Summary: New Class throws exception
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 06:57 EDT by Bob Foster CLA
Modified: 2004-02-23 16:42 EST (History)
1 user (show)

See Also:


Attachments
Visitor.java (4.25 KB, text/plain)
2003-04-08 06:59 EDT, Bob Foster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Foster CLA 2003-04-08 06:57:16 EDT
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
Comment 1 Bob Foster CLA 2003-04-08 06:59:54 EDT
Created attachment 4493 [details]
Visitor.java

This is the abstract superclass. I have performed this operation prior to 2.1
final without any problems.
Comment 2 Dirk Baeumer CLA 2003-04-08 08:31:43 EDT
Martin, can you please comment. 
Comment 3 Martin Aeschlimann CLA 2003-04-08 09:06:13 EDT
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
Comment 4 Olivier Thomann CLA 2003-04-08 09:38:50 EDT
I will investigate.
Comment 5 Olivier Thomann CLA 2003-04-08 14:27:18 EDT
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.
Comment 6 Bob Foster CLA 2003-04-08 18:19:11 EDT
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.
Comment 7 Olivier Thomann CLA 2003-04-09 10:29:29 EDT
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.
Comment 8 Olivier Thomann CLA 2003-04-09 10:37:36 EDT
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.
Comment 9 Bob Foster CLA 2003-04-10 00:59:13 EDT
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.
Comment 10 Olivier Thomann CLA 2003-04-15 13:43:49 EDT
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.
Comment 11 Martin Aeschlimann CLA 2003-04-16 03:31:47 EDT
There are no other threads involved in the creation of the class, but of course
the reconciler thread could interfere. Olivier, what about that?
Comment 12 Olivier Thomann CLA 2003-04-16 14:20:32 EDT
Bob, could it be possible that you had syntax error in your code?
Comment 13 Bob Foster CLA 2003-04-16 19:30:50 EDT
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. ;-}
Comment 14 Olivier Thomann CLA 2003-10-03 11:48:34 EDT
Did you get it lately using 3.0 integration build?
Comment 15 Olivier Thomann CLA 2004-02-23 16:42:28 EST
Closing as WORKSFORME.
Please reopen if you get it again.