Bug 120559 - Getting Javadoc from attached Javadoc gives JavaModelException
Summary: Getting Javadoc from attached Javadoc gives JavaModelException
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 120560
  Show dependency tree
 
Reported: 2005-12-13 08:31 EST by Dani Megert CLA
Modified: 2006-03-30 10:26 EST (History)
2 users (show)

See Also:


Attachments
Proposed fix (4.58 KB, patch)
2005-12-13 14:24 EST, Olivier Thomann CLA
no flags Details | Diff
Test workspace + configuration (105.97 KB, application/zip)
2006-03-27 10:30 EST, Damien Lecan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2005-12-13 08:31:40 EST
I20051213-0010

The spec says that 'null' is returned if the Javadoc can't be found:
  * <p>Returns the Javadoc as an html source if this element has an attached javadoc,
  * null otherwise.</p> 

but currently the code throws a JavaModelException:

java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
!SESSION 2005-12-13 14:24:45.074 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.4.2_08
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.sdk.ide -pdelaunch -showlocation
Command-line arguments:  -product org.eclipse.sdk.ide -data c:\eclipse\workspaces\Development_3_2\eoe -dev file:c:/eclipse/workspaces/Development_3_2/plugins/.metadata/.plugins/org.eclipse.pde.core/eoe (Sun)/dev.properties -pdelaunch -showlocation -consolelog -clean -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.jdt.ui 4 10001 2005-12-13 14:25:16.749
!MESSAGE Internal Error
!STACK 1
Java Model Exception: Java Model Status [Cannot retrieve the attached javadoc for s [in s.class [in com.sun.rsasign [in C:\JavaSDKs\jdk1.4.2_08\jre\lib\sunrsasign.jar [in JP]]]]]
	at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:991)
	at org.eclipse.jdt.ui.JavadocContentAccess.getHTMLContentReader(JavadocContentAccess.java:121)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.extractJavadoc(MemberProposalInfo.java:102)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.computeInfo(MemberProposalInfo.java:81)
	at org.eclipse.jdt.internal.ui.text.java.MemberProposalInfo.getInfo(MemberProposalInfo.java:68)
	at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getAdditionalProposalInfo(LazyJavaCompletionProposal.java:180)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221)
	at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:820)
	at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:810)
	at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173)
	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:3218)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2864)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1763)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1727)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:396)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:109)
	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:379)
	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:324)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
!SUBENTRY 1 org.eclipse.jdt.core 4 1008 2005-12-13 14:25:16.759
!MESSAGE Cannot retrieve the attached javadoc for s [in s.class [in com.sun.rsasign [in C:\JavaSDKs\jdk1.4.2_08\jre\lib\sunrsasign.jar [in JP]]]]
Comment 1 Olivier Thomann CLA 2005-12-13 09:15:55 EST
The specs also says:
	 * @exception JavaModelException if:<ul>
	 *  <li>this element does not exist</li>
	 *  <li>retrieving the attached javadoc fails (timed-out, invalid URL, ...)
	 *  <li>the format of the javadoc doesn't match expected standards (different anchors,...)</li>
	 *  </ul>

So if the javadoc cannot not be retrieved, it would make sense to return a JME.
Did I miss something?

null would be returned if the doc contents can be retrieved, but the part specific to the current java element cannot be extracted.
Comment 2 Dani Megert CLA 2005-12-13 09:22:11 EST
>null would be returned if the doc contents can be retrieved, but the part
>specific to the current java element cannot be extracted.
Exactly my point! The doc is there (http://java.sun.com/j2se/1.4.2/docs/api/) and can be accessed, so why do you throw the JME?
Comment 3 Olivier Thomann CLA 2005-12-13 09:24:45 EST
I will investigate.
So you are trying to get the doc for com.sun.rsasign.s type?
Comment 4 Dani Megert CLA 2005-12-13 09:27:30 EST
Yes that was the case where the error happend.

JME should only be thrown in case of error i.e. the location is not valid, exceptions occur or the Java element does not exist.

I think the only thing which is not yet fully clear when reading the Javadoc spec is what's happening when there's no attached Javadoc at all. I tend to say it should return 'null' and not a JME.
Comment 5 Olivier Thomann CLA 2005-12-13 09:32:13 EST
You are right. I would also expect null to be returned in this case.
I'll clarify the doc and fix the implementation.
Comment 6 Olivier Thomann CLA 2005-12-13 09:35:11 EST
In this case a JME is thrown only when the url is malformed. Because in this case I doubt that there is a doc for this class.
I'll see how to fix this.
Comment 7 Olivier Thomann CLA 2005-12-13 14:24:48 EST
Created attachment 31669 [details]
Proposed fix

I throw an JME when I get a IOException reading the doc or a MalformedURLException.
If I get a FileNotFoundException (the case you describe), I simply return null. This will be an unoptimized case for the cache since it always ends up being null.
Comment 8 Olivier Thomann CLA 2005-12-13 14:26:19 EST
We might want to return a default value (different from null) to handle the caching issue.
Comment 9 Philipe Mulet CLA 2005-12-13 14:33:04 EST
+1 for M4
Comment 10 Olivier Thomann CLA 2005-12-13 15:04:02 EST
Fixed and released in HEAD.
I also added this line to the spec.
<p>In case of the javadoc doesn't exist for this element, null is returned.</p>
Comment 11 Olivier Thomann CLA 2005-12-13 15:44:14 EST
Added regression test in org.eclipse.jdt.core.tests.model.AttachedJavadocTests.test013
Comment 12 Frederic Fusier CLA 2005-12-14 06:38:31 EST
Verified for 3.2 M4 using build I20051214-0010.
Comment 13 Eric Moffatt CLA 2006-01-04 16:01:51 EST
Olivier, I'm seeing this in 3.2M4...

every time I hover over a field / method that doesn't have javadoc I see a "Internal error logged from JDI Debug" showing up in my Error Log (which keeps opening because I have it as a Fast View, making it -REALLY- hard to work).

Comment 14 Olivier Thomann CLA 2006-01-04 19:41:54 EST
Is this really the same problem?
Do you have a stack trace to submit?
I'll check with you tomorrow.
Comment 15 Dani Megert CLA 2006-01-05 02:47:30 EST
This rather looks like problem/bug in the debug hover.
Comment 16 Eric Moffatt CLA 2006-01-05 16:17:02 EST
I've just spent a fair bit of time trying to repro again because the problem has gone away on the class that I was getting the errors for (just like bringing the car to the mechanic...;-). No success so far but I'll keep my eyes open and get Olivier if I ever see the state again.

I think Daniel's hit it...here's my stack trace...

org.eclipse.debug.core.DebugException: Unable to retrieve types - VM disconnected.
	at org.eclipse.jdt.internal.debug.core.model.JDIDebugElement.throwDebugException(JDIDebugElement.java:203)
	at org.eclipse.jdt.internal.debug.core.model.JDIDebugElement.requestFailed(JDIDebugElement.java:158)
	at org.eclipse.jdt.internal.debug.core.model.JDIDebugElement.requestFailed(JDIDebugElement.java:129)
	at org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.getJavaTypes(JDIDebugTarget.java:1510)
	at org.eclipse.jdt.internal.debug.ui.JavaDebugHover.getHoverInfo(JavaDebugHover.java:137)
	at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
	at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
Comment 17 Damien Lecan CLA 2006-03-10 07:55:10 EST
I have the same problem.

I just ask for completion, and Eclipse freeze for 2-3 min.
I work with Eclipse 3.2M5, on Java 1.5.0_06. src.zip is correctly attached to jdk classes. It works on java.* and javax.* classes.

Java Model Exception: Java Model Status [Cannot retrieve the attached javadoc for l [in l.class [in sun.security.krb5.internal.ktab [in D:\jdk1.5.0_06\jre\lib\rt.jar [in VLA]]]]]
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:770)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1075)
at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:998)
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:412)
at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getAdditionalProposalInfo(LazyJavaCompletionProposal.java:236)
at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221)
at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:820)
at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:810)
at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173)
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:3264)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2910)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1899)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1863)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:417)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:99)
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:374)
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:338)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 18 Olivier Thomann CLA 2006-03-10 09:22:24 EST
Reopening.
Damien,

Could you please provide steps to reproduce?
Comment 19 Damien Lecan CLA 2006-03-10 11:22:02 EST
- Fresh install of Eclipse 3.2M5
- New workspace
- Let Eclipse to configure detected default JRE (for me : C:\Program Files\Java\jre1.5.0_06).
- Create a new class
- Inside the class, try to get completion for 'l' for example. Eclipse freezes for 2-3 min.

If I use a jre for compilation, eclipse freezes anytime, for any class
If I use a jre/jdk with attached sources, eclipse freezes for any class that has not source attachement (eg : a sun.* class).

In fact, with sources attachement, not problem. But sun classes appears always at the beginning of the completion list, and they haven't source attachement.
Comment 20 Olivier Thomann CLA 2006-03-13 11:10:39 EST
I tried your steps and I don't get any delay. I get the completion list pretty fast (below 1s).
Comment 21 Damien Lecan CLA 2006-03-21 05:09:30 EST
Sorry for the delay.

Some other members of my team have the same problem. For me, the problem still happens.

If I write 'ad' in a class and ask for completion, 'ad - sun.securoty.krb5.internal' appears first, and Eclipse is blocked for 1 minute. In error log file, same stacktrace as before is written.

What can I provide you to help you to make a diagnostic ?
Comment 22 Olivier Thomann CLA 2006-03-21 09:43:37 EST
If you could provide a test case like your workspace, this might help me to identify the problem.
Right now I don't get any delay. Is it always slow or only the first time you use code assist?
Comment 23 Damien Lecan CLA 2006-03-24 10:30:58 EST
It is always very slow if no source is attached to a specified class

Another kind of exception :

Java Model Exception: Java Model Status [Cannot retrieve the attached javadoc for logging [in logging.class [in sun.util.logging.resources [in D:\jdk1.5.0_06\jre\lib\rt.jar [in BMW-VLA]]]]]
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:770)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1075)
at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:998)
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:412)
at org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal.getAdditionalProposalInfo(LazyJavaCompletionProposal.java:236)
at org.eclipse.jface.text.contentassist.AdditionalInfoController.computeInformation(AdditionalInfoController.java:221)
at org.eclipse.jface.text.AbstractInformationControlManager.doShowInformation(AbstractInformationControlManager.java:820)
at org.eclipse.jface.text.AbstractInformationControlManager.showInformation(AbstractInformationControlManager.java:810)
at org.eclipse.jface.text.contentassist.AdditionalInfoController$1.run(AdditionalInfoController.java:173)
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:3264)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2910)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1899)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1863)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:417)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:99)
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:374)
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:338)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 24 Olivier Thomann CLA 2006-03-24 10:34:43 EST
How did you get this stack trace?
Comment 25 Damien Lecan CLA 2006-03-24 10:42:37 EST
Strack trace comes from <WORKSPACE>/.metadata/.log

Eclipse version :
Version: 3.2.0
Build id: I20060217-1115

This is Eclipse 3.2.0M5 I guess
Comment 26 Olivier Thomann CLA 2006-03-24 10:53:14 EST
Do you get it all the time?
I don't understand how you are getting the IOException.
Would it be possible for you to move to latest integration build 	I20060322-1335 and I would provide you with a patch that would dump the stack trace for the IOException ?

Could you please attach your configuration ?

Help>About Eclipse SDK>Configuration Details>Copy to Clipboard. Save it to a file and attach it to this bug report please. 
Comment 27 Damien Lecan CLA 2006-03-27 10:02:43 EST
- Fresh install of Eclipse I20060322-1335
- New workspace
- New Java project
- Create a new class (Test for example)
- Inside the class, try to get completion for 'l', or 'a' for example. Eclipse freezes for 2-3 min.

In the .log file appears :
!ENTRY org.eclipse.jdt.ui 4 10001 2006-03-27 16:52:40.080
!MESSAGE Internal Error
!STACK 1
Java Model Exception: Java Model Status [Cannot retrieve the attached javadoc for l [in l.class [in sun.security.krb5.internal.ktab [in C:\Program Files\Java\jre1.5.0_06\lib\rt.jar [in Test]]]]]

See attached file for details
Comment 28 Damien Lecan CLA 2006-03-27 10:30:45 EST
Created attachment 36991 [details]
Test workspace + configuration

Test workspace (for .log error file) + configuration file
Comment 29 Olivier Thomann CLA 2006-03-27 10:55:42 EST
I used your test case I could get the lag you descrived. It takes around 1s to get the code assist completion.
Would it be possible for you to use a modified version of jdt/core that would dump the IOException stack trace?
I cannot get this IOException. So something must be different on your machine. Maybe the IOException gives us some details why it occured.
Comment 30 Olivier Thomann CLA 2006-03-27 11:37:44 EST
Are you behind a firewall ?
Comment 31 Olivier Thomann CLA 2006-03-27 12:14:58 EST
I believe you are behind a firewall and you got a ConnectException while trying to retrieve the javadoc.
In this case I could treat it like a FileNotFoundException and prevent to log an error in the .log file.
Daniel, do you think this could be handled that way? Checking the spec, it doesn't look wrong to log an error.
Comment 32 Dani Megert CLA 2006-03-27 14:47:09 EST
I think we're mixing things here in this bug. The original report was that the Javadoc in general could be reached but not the desired element - hence 'null' is expected and not a JME - this got fixed. Afterwards this bug was misused for another scenario where accessing Javadoc times-out. In this scenario the JME is correct as speced. Either open up the firewall or download and install the Javadoc locally.
Comment 33 Olivier Thomann CLA 2006-03-27 14:53:21 EST
For the 20060327-1600 build, I added extra tracing to get the stack trace of the IOException thrown in this case.
This will help to identify the cause of the problem for sure.
I am closing this one as FIXED and VERIFIED.
Damien, please refer to bug 133348 about the firewall issue.
Comment 34 Olivier Thomann CLA 2006-03-27 14:53:48 EST
Verified.
Comment 35 Dani Megert CLA 2006-03-30 10:26:01 EST
*** Bug 134061 has been marked as a duplicate of this bug. ***