Bug 214647 - [dom] NPE in MethodBinding.getParameterAnnotations(..)
Summary: [dom] NPE in MethodBinding.getParameterAnnotations(..)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-08 13:04 EST by Markus Keller CLA
Modified: 2008-02-05 04:54 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.85 KB, patch)
2008-01-08 13:20 EST, Olivier Thomann CLA
no flags Details | Diff
New proposed patch (5.60 KB, patch)
2008-01-08 13:53 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-01-08 13:04:11 EST
HEAD (with fix for bug 213509, e.g. N20080108-0010)

- install and open ASTView
- have:
public class Try {
	void m(Object o) { }
}
- select "m"
- in ASTView, click the "Show AST of active Editor" toolbar button

=> error dialog, NPE below in log

java.lang.NullPointerException
        at org.eclipse.jdt.core.dom.MethodBinding.getParameterAnnotations(MethodBinding.java:145)
        at org.eclipse.jdt.astview.views.Binding.getChildren(Binding.java:219)
        at org.eclipse.jdt.astview.views.ASTViewContentProvider.getChildren(ASTViewContentProvider.java:95)
        at org.eclipse.jdt.astview.views.ASTViewContentProvider.hasChildren(ASTViewContentProvider.java:226)
        at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2045)
        at org.eclipse.jface.viewers.TreeViewer.isExpandable(TreeViewer.java:575)
        at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:2071)
        at org.eclipse.jface.viewers.AbstractTreeViewer.updatePlus(AbstractTreeViewer.java:2713)
        at org.eclipse.jface.viewers.TreeViewer.updatePlus(TreeViewer.java:835)
        at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:825)
        at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:799)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
        at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:773)
        at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:627)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpand(AbstractTreeViewer.java:1575)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpand(AbstractTreeViewer.java:1572)
        at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2417)
        at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1680)
        at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2825)
        at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1636)
        at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:1095)
        at org.eclipse.jdt.astview.views.ASTView.internalSetInput(ASTView.java:551)
        at org.eclipse.jdt.astview.views.ASTView.setInput(ASTView.java:517)
        at org.eclipse.jdt.astview.views.ASTView.performSetFocus(ASTView.java:1222)
        at org.eclipse.jdt.astview.views.ASTView$19.run(ASTView.java:962)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:582)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:499)
        at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:451)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3758)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3369)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2392)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2222)
        at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:469)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
        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:561)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:501)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1239)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1215)
Comment 1 Olivier Thomann CLA 2008-01-08 13:16:08 EST
Missing a null check.
Frédéric, you might also want to make sure that this is thread safe.
Comment 2 Olivier Thomann CLA 2008-01-08 13:20:25 EST
Created attachment 86415 [details]
Proposed fix

Need to be reviewed (untested) + addition of regression tests.
Comment 3 Frederic Fusier CLA 2008-01-08 13:53:43 EST
Created attachment 86417 [details]
New proposed patch

I prefer to store an empty array rather than testing for null on several lines. Then I avoid to get potential problem with synchronization.
This patch also includes 2 test cases on ASTConverterBugsTest.

I'll release it as soon as all JDT tests pass...
Comment 4 Frederic Fusier CLA 2008-01-08 17:12:08 EST
Released for 3.4M5 in HEAD stream.
Comment 5 Frederic Fusier CLA 2008-01-09 07:17:26 EST
Comment on attachment 86417 [details]
New proposed patch

Talking with Jerome about my changes leads to prefer the Olivier's patch which does not store empty arrays when there's no annotation at all.
Comment 6 Frederic Fusier CLA 2008-01-09 07:18:11 EST
Comment on attachment 86415 [details]
Proposed fix

This was finally this patch I released + new added tests...
Comment 7 Maxime Daniel CLA 2008-02-05 04:54:15 EST
Verified for 34M5 using I20080204-0010 build.