Bug 74014 - prefix path for source attachements - automatic detection does not seem to work
Summary: prefix path for source attachements - automatic detection does not seem to work
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: 3.0.2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-15 15:54 EDT by Luce Vassallo CLA
Modified: 2005-01-26 12:48 EST (History)
0 users

See Also:


Attachments
The jar to put on the build path (1.14 KB, application/x-zip-compressed)
2004-09-17 06:01 EDT, Jerome Lanneluc CLA
no flags Details
reproduces the "source not found" symptom (1.96 KB, application/x-zip-compressed )
2004-09-20 15:37 EDT, Luce Vassallo CLA
no flags Details
jar that does not reproduce the "source not found" problem (2.08 KB, application/x-zip-compressed )
2004-09-20 15:43 EDT, Luce Vassallo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luce Vassallo CLA 2004-09-15 15:54:24 EDT
I understand that in Eclipse 3.0 the prefix path for source jars attachments
(the "root path" field in Attach Source dialog for previous versions)is now 
automatically "inferred". This does not seem to work for jars contributed by 
one of our vendors who uses the following pattern when packaging : 
- .class files and .java files are located in the same jar
- .class files are located under xxx/yyy, where "xxx.yyy" is the correct 
package name
- .java files are located under corejrisk/src/xxx/yyy

Now in my beloved 2.0.1 version of Eclipse I simply set "root path" 
to "corejrisk/src" when attaching the source jar and it works perfectly. I also 
understand that the "rootpath" attribute in the matching .classpath entry was 
supported in more recent versions even after the "root path" field had 
disappeared from the Attach Source dialog. But in the 3.0 version 
the "rootpath" attribute no longer seems to work, while the "inference" 
mechanism apparently fails to pick up the appropriate source file. People 
around me have resorted to unzipping the source files to folders, but this is a 
pain as we incorporate new jars of that type on a regular basis.
I perused the Newsgroup on dev.eclipse.org and found an entry for this problem, 
dated Sep. 15 2003, where the conclusion was :
"The prefix path should be automatically detected now. If it is not in your
case, please enter a bug against JDT/Core with steps to reproduce the
problem."

The exact Eclipse version I am referring to is 3.0.0, build 200406251208.
Comment 1 Jerome Lanneluc CLA 2004-09-17 06:01:01 EDT
From your decription, I created a Java project with the attached jar on its 
build path. I attached the same jar as its own source attachment and I was 
able to see the source of X.class.

Did I miss something ?
Comment 2 Jerome Lanneluc CLA 2004-09-17 06:01:32 EDT
Created attachment 14606 [details]
The jar to put on the build path
Comment 3 Luce Vassallo CLA 2004-09-20 15:37:57 EDT
Created attachment 14659 [details]
reproduces the "source not found" symptom

Took a harder look at the vendor jar and it seems that what gets Eclipse
confused is the presence of another .class file for the same object but with a
different path. This other path starts with the same folder name as the source
file path, and that seems to have a bearing on the problem (see the other
attachement).
Comment 4 Luce Vassallo CLA 2004-09-20 15:43:15 EDT
Created attachment 14660 [details]
jar that does not reproduce the "source not found" problem

Now this jar is very similar to the "repro.jar" one except that the "parasite"
.class object has a completely unrelated path (no common prefix with source
file path). In this configuration Eclipse has no problem retrieving the source
file.
Comment 5 Luce Vassallo CLA 2004-09-20 16:09:47 EDT
Ran a couple of other tests on path for 'parasite' .class object : 
 - tried "anotherpath/corejrisk/lib/xxx/yyy" : works fine
 - tried "lib/xxx/yyy" : also OK
From here it looks like it's the initial folder identity that creates the 
confusion. Unfortunately for us this is just the way all those jars are 
packaged.

I tried all these test jars in my 2.0.1 Eclipse and, with the correct setting 
for the "root path" field, have no problem accessing the source code. So to me 
it does feel like a regression.
Comment 6 Jerome Lanneluc CLA 2004-09-21 12:04:54 EDT
Thanks for taking the time to give a good test case. I was able to reproduce 
the problem with the attached jar.

Problem is that SourceMapper#computeAllRootPaths(...) stops at the 
first 'first level package name'. If a .class file is included in several root 
paths, only the first root path will be considered.

Fixed SourceMapper#computeAllRootPaths(...) to consider the whole path of an 
entry (also changed it to skip non-java entries).

Added regression test AttachSourceTests#testRootPath12()

Released in both HEAD and R3_0_maintenance branches.
Comment 7 Frederic Fusier CLA 2004-09-23 12:12:05 EDT
Verified for 3.1 M2 with build I200409230800.
Comment 8 Jerome Lanneluc CLA 2005-01-26 12:46:00 EST
Candidating for 3.0.2
Comment 9 Jerome Lanneluc CLA 2005-01-26 12:48:06 EST
Note this is not committed yet