Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362221

Summary: Javadoc Location Manager returns wrong Javadoc URL on Linux/MacOS
Product: [Eclipse Project] PDE Reporter: Marcelo Bossoni <mmbossoni>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Olivier_Thomann
Version: 3.7.1   
Target Milestone: 3.8 M4   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Marcelo Bossoni CLA 2011-10-27 13:14:09 EDT
Build Identifier: 3.7.0

I'm developing some plugins and exporting its javadoc by adding a doc folder withing the generated jar file.

JDT uses the JavadocLocationManager.getJavadocLocation method that returns wrong URLs for Linux and MacOS.

The current implementation adds an extra "/" in the URL causing errors. So, instead of URL being something like file:/home/myhome/eclipse/plugins/myplugin.jar it is file://home/myhome/eclipse/plugins/myplugin.jar

CURRENT IMPLEMENTATION

	File file = new File(model.getInstallLocation());
 		if (file.isDirectory()) {
 			File doc = new File(file, "doc"); //$NON-NLS-1$
 			if (new File(doc, "package-list").exists()) //$NON-NLS-1$
 				return "file:/" + doc.getAbsolutePath(); //$NON-NLS-1$
 		} else if (CoreUtility.jarContainsResource(file, "doc/package-list", false)) { //$NON-NLS-1$
 			return "jar:file:/" + file.getAbsolutePath() + "!/doc"; //$NON-NLS-1$ //$NON-NLS-2$


SUGGESTION

	File file = new File(model.getInstallLocation());
 		if (file.isDirectory()) {
 			File doc = new File(file, "doc"); //$NON-NLS-1$
 			if (new File(doc, "package-list").exists()) //$NON-NLS-1$
 				return "file:" + (Platform.OS_WIN32.equals(Platform.getOS()) ? "/" : "" ) + doc.getAbsolutePath(); //$NON-NLS-1$
 		} else if (CoreUtility.jarContainsResource(file, "doc/package-list", false)) { //$NON-NLS-1$
 			return "jar:file:" + (Platform.OS_WIN32.equals(Platform.getOS()) ? "/" : "" ) + file.getAbsolutePath() + "!/doc"; //$NON-NLS-1$ //$NON-NLS-2$




Reproducible: Always
Comment 1 Olivier Thomann CLA 2011-10-27 13:56:27 EDT
Move to PDE/UI
Comment 2 Curtis Windatt CLA 2011-10-31 14:53:53 EDT
Fixed in master.  I replaced the string concatenation with a File.toURL().  This method has been deprecated in later versions of the JDK as it does not encode special characters.  However, we haven't ever done encoding here and the method will handle the slashes correctly.

Try it out and let us know if it fixes your problem.
Comment 3 Marcelo Bossoni CLA 2011-11-01 08:48:29 EDT
How can I get a build with this fix?
Comment 4 Curtis Windatt CLA 2011-11-01 09:30:04 EDT
(In reply to comment #3)
> How can I get a build with this fix?

As Dani already mentioned on the mailing list, the first build containing the change will be:

http://download.eclipse.org/eclipse/downloads/drops/N20111031-2000

However, that link is not available yet (hasn't sync'd).  Not sure if there is something wrong or if it is just slow. There is an I Build today that will also include the fix.