Bug 139160 - IMethod#getParameterNames() should not throw JME if javadoc not parseable
Summary: IMethod#getParameterNames() should not throw JME if javadoc not parseable
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 RC3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-28 10:03 EDT by Markus Keller CLA
Modified: 2006-05-04 09:26 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.58 KB, patch)
2006-04-28 22:48 EDT, Olivier Thomann CLA
no flags Details | Diff
Better patch (2.15 KB, patch)
2006-05-01 22:01 EDT, Olivier Thomann 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 2006-04-28 10:03:23 EDT
I20060428-0010

IMethod#getParameterNames() should not throw JME if javadoc is not parseable or not available. Currently, it e.g. throws an exception when  called on a private binary method where a source attachment is not avaliable and the javadoc does not include private members.

Steps:

Open Java Editor on java.util.Collections from a 1.5 rt.jar and select
    iteratorBinarySearch(List<? extends Comparable<? super T>>, T)
in the Outline.

The exception occurs because the status line wants to display the parameter names (source is not available for this method due to bug xxx). If you remove the source from the rt.jar, it also fails for all the other private methods.


Java Model Exception: Java Model Status [Unknown javadoc format for iteratorBinarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T) [in Collections [in Collections.class [in java.util [in C:\java\jdk1.5.0_06\jre\lib\rt.jar [in JUnit1.5]]]]]]
	at org.eclipse.jdt.internal.core.BinaryMethod.extractJavadoc(BinaryMethod.java:596)
	at org.eclipse.jdt.internal.core.BinaryMethod.getParameterNames(BinaryMethod.java:230)
	at org.eclipse.jdt.ui.JavaElementLabels.getMethodLabel(JavaElementLabels.java:531)
	at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:418)
	at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:395)
	at org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater.formatJavaElementMessage(StatusBarUpdater.java:89)
	at org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater.formatMessage(StatusBarUpdater.java:71)
	at org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater.selectionChanged(StatusBarUpdater.java:56)
	at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:833)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
	at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:831)
	at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:1137)
	at org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(StructuredViewer.java:1157)
	at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:236)
	at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:230)
	at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:404)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.eclipse.pde.internal.runtime.logview.EventDetailsDialog.open(EventDetailsDialog.java:183)
	at org.eclipse.pde.internal.runtime.logview.EventDetailsDialogAction.run(EventDetailsDialogAction.java:91)
	at org.eclipse.pde.internal.runtime.logview.LogView$13.doubleClick(LogView.java:403)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:790)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:788)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1210)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1152)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:223)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:220)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:281)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 1 Olivier Thomann CLA 2006-04-28 22:03:41 EDT
Then if the anchor is not found, I should not log an error.
But this could have two explanations: wrong computing of the anchor or missing anchor.
Do you suggest not to log any exception in both cases?
Comment 2 Olivier Thomann CLA 2006-04-28 22:48:07 EDT
Created attachment 39858 [details]
Proposed fix

Philippe,

Candidate for RC3?
Comment 3 Olivier Thomann CLA 2006-04-30 21:15:11 EDT
Philippe,

Candidate for RC3?
Comment 4 Markus Keller CLA 2006-05-01 13:45:14 EDT
(In reply to comment #1)
> Then if the anchor is not found, I should not log an error.
> But this could have two explanations: wrong computing of the anchor or missing
> anchor.
> Do you suggest not to log any exception in both cases?

Yes. People will file bugs anyway if javadoc attachments don't show up, so we don't need an exception. Missing anchors have to be expected with partial, outdated, or customized javadoc, and no exception should be thrown for expected failures.

However, I think this only applies to IJavaElement#getAttachedJavadoc(..). For the case in comment 0, the fix should also make sure that IMethod#getParameterNames() never throws a JME, not even if the Javadoc is malformed or something (i.e. add a try {..} catch (JavaModelException e) { } around BinaryMethod.java:230, rev. 1.89).
Comment 5 Olivier Thomann CLA 2006-05-01 22:01:23 EDT
Created attachment 40016 [details]
Better patch

This patch adds a try/catch around the extraction of the javadoc for the binary method.
Comment 6 Olivier Thomann CLA 2006-05-01 22:02:30 EDT
Candidate for RC3?
Patch is ready.
Comment 7 Philipe Mulet CLA 2006-05-02 09:29:34 EDT
+1 for 3.2RC3. Being resilient is good here. It will revert to inferring arg0... argN.

Dani/Markus - pls cast your vote.
Comment 8 Dani Megert CLA 2006-05-02 09:38:36 EDT
+1 for 3.2 RC3.
Comment 9 Olivier Thomann CLA 2006-05-02 12:20:25 EDT
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.model.AttachedJavadocTests.test020
Comment 10 Olivier Thomann CLA 2006-05-03 11:03:06 EDT
Verified using N20060503-0010 for 3.2RC3
Comment 11 Frederic Fusier CLA 2006-05-04 09:26:40 EDT
Double-checked using N20060504-0010 + JDT/Core v_663.
Note that this exception does not occur with 3.2 RC2 but only with I20060428-0010.