Bug 138167 - Java Model Exception when proposal window opened
Summary: Java Model Exception when proposal window opened
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-23 22:25 EDT by Alex Chapiro CLA
Modified: 2006-04-28 14:11 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (10.91 KB, patch)
2006-04-24 23:56 EDT, Olivier Thomann CLA
no flags Details | Diff
Better patch (9.54 KB, patch)
2006-04-25 12:14 EDT, Olivier Thomann CLA
no flags Details | Diff
Last patch (8.75 KB, patch)
2006-04-25 16:11 EDT, Olivier Thomann CLA
no flags Details | Diff
Patch with checks (9.50 KB, patch)
2006-04-26 10:44 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 Alex Chapiro CLA 2006-04-23 22:25:51 EDT
How to reproduce:
Type:
List a = new ArrayList();
a.toA

and press Ctrl-Space. Proposition window comes up. Press Down Arrow and look up to the error log. The following trace is there:

Java Model Exception: Java Model Status [Unknown javadoc format for toArray(T[]) [in List [in List.class [in java.util [in C:\Program Files\Java\jre1.5.0_05\lib\rt.jar [in External Plug-in Libraries]]]]]]
	at org.eclipse.jdt.internal.core.BinaryMethod.extractJavadoc(BinaryMethod.java:528)
	at org.eclipse.jdt.internal.core.BinaryMethod.getAttachedJavadoc(BinaryMethod.java:469)
	at org.eclipse.jdt.ui.JavadocContentAccess.getHTMLContentReader(JavadocContentAccess.java:121)
	at org.eclipse.jdt.internal.ui.text.java.ProposalInfo.extractJavadoc(ProposalInfo.java:92)
	at org.eclipse.jdt.internal.ui.text.java.ProposalInfo.computeInfo(ProposalInfo.java:70)
	at org.eclipse.jdt.internal.ui.text.java.ProposalInfo.getInfo(ProposalInfo.java:54)
	at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.getAdditionalProposalInfo(AbstractJavaCompletionProposal.java:438)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getAdditionalProposalInfo(LazyJavaCompletionProposal.java:236)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:222)
	at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:821)
	at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:811)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:174)
	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:3323)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2969)
	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:376)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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)


I'm using Java 5 in Java 1.4 compatibility mode.
Comment 1 Dani Megert CLA 2006-04-24 10:10:36 EDT
I can reproduce this using Sun 5.0_06 (http://java.sun.com/j2se/1.5.0/docs/api/). It seems that JDT Core cannot retrieve the Javadov for ArrayList.toArray(Object[])

It works for http://java.sun.com/j2se/1.4.2/docs/api/
Comment 2 Olivier Thomann CLA 2006-04-24 11:46:03 EDT
Philippe,

Candidate for RC2?
I am investigating it.
Comment 3 Olivier Thomann CLA 2006-04-24 23:56:09 EDT
Created attachment 39389 [details]
Proposed fix

The patch is extracting the right information out of the generic signature of the generic method when there is one.
With this patch, I can successfully get the javadoc for all methods in java.util.List or java.util.Collections.
Comment 4 Philipe Mulet CLA 2006-04-25 10:42:10 EDT
+1 for 3.2RC2.

Jerome - pls review the patch
Comment 5 Olivier Thomann CLA 2006-04-25 12:14:56 EDT
Created attachment 39421 [details]
Better patch

This patch reorganized the previous patch by moving the code into the Util class to build the anchor string.
Comment 6 Olivier Thomann CLA 2006-04-25 16:11:57 EDT
Created attachment 39464 [details]
Last patch

This last patch is removing some check and add a try/catch in Util.toAnchor(...). If null is returned, this is logged as an unknown format so we can find out cases that would fail.
I can successfully retrieve the javadocs for all methods from java.util.List or java.util.Collections.
Merging these new append... methods with the existing one from Util isn't really useful. Actual methods return void and these methods need to return an int.
This would not make the code more legible.
Comment 7 Olivier Thomann CLA 2006-04-25 16:44:00 EDT
Added regression test18 in org.eclipse.jdt.core.tests.model.AttachedJavadocTests.
It is disabled for now.
Jérôme, please enable it once the patch is released.
Comment 8 Jerome Lanneluc CLA 2006-04-25 18:15:53 EDT
I would not catch RuntimeException without logging. Since you're doing all the checks and throwing IllegalArgumentException, I would just catch IllegalArgumentException. Then no logging would be necessary.
Comment 9 Olivier Thomann CLA 2006-04-25 21:14:08 EDT
I am logging.
if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this));

This is enough to log that a problem happened opening a specific type, isn't it?
Comment 10 Jerome Lanneluc CLA 2006-04-26 04:26:19 EDT
If the RuntimeException is not an IllegalArgumentException, you're losing this information. Why do you need to catch more than IllegalArgumentException ?
Comment 11 Olivier Thomann CLA 2006-04-26 10:07:25 EDT
Since I removed the checks for the bounds I could also have AIOOBE.
I can put the check back and then I don't expect anything else than IllegalArgumentException.
Comment 12 Jerome Lanneluc CLA 2006-04-26 10:09:40 EDT
Yes that would be better
Comment 13 Olivier Thomann CLA 2006-04-26 10:44:28 EDT
Created attachment 39534 [details]
Patch with checks

Jérôme,
This patch has all the checks and catches only IllegalArgumentException.
Ok to release?
Comment 14 Jerome Lanneluc CLA 2006-04-26 10:51:18 EDT
OK to release
Comment 15 Olivier Thomann CLA 2006-04-26 13:01:06 EDT
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.model.AttachedJavadocTests.test018
Comment 16 Olivier Thomann CLA 2006-04-28 14:11:27 EDT
Verified with I20060427-1600 for 3.2RC2