Bug 348507 - [search] Hyperlinks from the Java Stack Trace console should search the workspace in CLASSPATH order
Summary: [search] Hyperlinks from the Java Stack Trace console should search the works...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M2   Edit
Assignee: Satyam Kandula CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 363512 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-06-07 03:44 EDT by Nikolay Botev CLA
Modified: 2020-12-07 05:11 EST (History)
5 users (show)

See Also:


Attachments
patch with fix (2.78 KB, patch)
2011-06-07 03:46 EDT, Nikolay Botev CLA
no flags Details | Diff
updated patch (3.77 KB, patch)
2011-06-21 02:01 EDT, Nikolay Botev CLA
satyam.kandula: iplog+
satyam.kandula: review+
Details | Diff
workspace wtih testcase involving 2 projects (42.23 KB, application/x-xz-compressed-tar)
2011-06-21 02:09 EDT, Nikolay Botev CLA
no flags Details
Junit test (3.07 KB, patch)
2011-08-19 12:10 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Botev CLA 2011-06-07 03:44:24 EDT
Build Identifier: I20110603-0909

for those of us unfortunate enough to work on huge poorly modularized projects, it is sometimes useful to have jars on the classpath that have the same classes as the ones in our source directory.

these duplicate entries sometimes confuse eclipse and the stacktrace console links will try to open the class files from the JARs on the classpath instead of reading the java files from the source directory.

this is ultimately because the stack trace console searches the indexes in effectively random order (based on the iteration order of a hash set).



Reproducible: Sometimes

Steps to Reproduce:
1. create a project with a main class that prints an exception stacktrace
2. create a jar from the project 
3. add the jar to the project's classpath
4. now you have the main class coming from both the source directory entry and the jar on the classpath. this is ok because the entries on the classpath are ordered and the source entry comes first.
5. add many more jars on the classpath to make things more randomized
6. run the main program and click on the hyperlink from the stacktrace that shows up in the process console
7. if you are lucky the java source file will open. if not, the class file from the jar will be open in an editor and an error message about an invalid line number will appear (since you did not add a source attachment to the jar).
Comment 1 Nikolay Botev CLA 2011-06-07 03:46:46 EDT
Created attachment 197481 [details]
patch with fix

this is a fix that modifies the 2 places in the code where the classpath entries are added into sets to use LinkedHashSet instead of whatever set they were using before. this effectively fixes the problem by defining a simple ordering rule for merging classpaths of multiple projects.
Comment 2 Ayushman Jain CLA 2011-06-07 04:17:15 EDT
Satyam, please follow up for 3.8. Thanks!
Comment 3 Satyam Kandula CLA 2011-06-08 02:10:46 EDT
(In reply to comment #1)
Thanks for your patch and this is good. Some minor comments:

1. However, I think it is better to extend to even multiple projects. Here are the steps to reproduce:
    1. Create two projects: ProjectA and ProjectB and create some classes in both of them.
    2. Export ProjectA into a jar and put as a dependency for projectB. 
    3. Export Project B into a jar and put as a dependency for projectA. 
    4. Make code changes such that the exception has both the classes in the exception. 
    5. Run the main program and click on the hyperlinks from the stacktrace

Let me know if you want to fix this problem too in your patch. 

2. IndexSelector.java - The change of locations.toArray() is good enough and the subsequent for loop is not necessary and can be removed. 

3. Can you please add your name in the copyright of the file? 

I will try to add a test and also try to run some performance tests to make sure that there is no performance regression.
Comment 4 Nikolay Botev CLA 2011-06-09 11:29:56 EDT
(In reply to comment #3)

Satyam,

1. I will attempt to update the patch to pull all the source classpath entries up to the front. If there is more than one project containing the same java class, there is still an ambiguity as to which one will get selected. At that point it might be best to pull up the Open Type dialog, but I don't know how easy that would be and not sure if I will have the time to spend on this. For my purpose the current state of the fix even though incomplete is good enough.

2. I will update the patch to avoid the double-copy of the array.

Thanks for the quick feedback

> (In reply to comment #1)
> Thanks for your patch and this is good. Some minor comments:
> 
> 1. However, I think it is better to extend to even multiple projects. Here are
> the steps to reproduce:
>     1. Create two projects: ProjectA and ProjectB and create some classes in
> both of them.
>     2. Export ProjectA into a jar and put as a dependency for projectB. 
>     3. Export Project B into a jar and put as a dependency for projectA. 
>     4. Make code changes such that the exception has both the classes in the
> exception. 
>     5. Run the main program and click on the hyperlinks from the stacktrace
> 
> Let me know if you want to fix this problem too in your patch. 
> 
> 2. IndexSelector.java - The change of locations.toArray() is good enough and
> the subsequent for loop is not necessary and can be removed. 
> 
> 3. Can you please add your name in the copyright of the file? 
> 
> I will try to add a test and also try to run some performance tests to make
> sure that there is no performance regression.
Comment 5 Nikolay Botev CLA 2011-06-21 02:00:57 EDT
Satyam,

I have incorporated all of your feedback.

Please let me know how it looks.

Thanks


(In reply to comment #3)
> (In reply to comment #1)
> Thanks for your patch and this is good. Some minor comments:
> 
> 1. However, I think it is better to extend to even multiple projects. Here are
> the steps to reproduce:
>     1. Create two projects: ProjectA and ProjectB and create some classes in
> both of them.
>     2. Export ProjectA into a jar and put as a dependency for projectB. 
>     3. Export Project B into a jar and put as a dependency for projectA. 
>     4. Make code changes such that the exception has both the classes in the
> exception. 
>     5. Run the main program and click on the hyperlinks from the stacktrace
> 
> Let me know if you want to fix this problem too in your patch. 
> 
> 2. IndexSelector.java - The change of locations.toArray() is good enough and
> the subsequent for loop is not necessary and can be removed. 
> 
> 3. Can you please add your name in the copyright of the file? 
> 
> I will try to add a test and also try to run some performance tests to make
> sure that there is no performance regression.
Comment 6 Nikolay Botev CLA 2011-06-21 02:01:31 EDT
Created attachment 198304 [details]
updated patch

for your review.
Comment 7 Nikolay Botev CLA 2011-06-21 02:09:21 EDT
Created attachment 198306 [details]
workspace wtih testcase involving 2 projects

... as described in comment #3
Comment 8 Markus Keller CLA 2011-08-08 06:03:30 EDT
See also bug 138377.
Comment 9 Nikolay Botev CLA 2011-08-18 17:49:40 EDT
Hi,

This is a critical issue for us at my company. 

Can this be integrated in a 3.7 point release?

Is there anything else that is needed from me?

Thanks
Comment 10 Srikanth Sankaran CLA 2011-08-19 01:05:31 EDT
(In reply to comment #9)
> Hi,
> 
> This is a critical issue for us at my company. 
> 
> Can this be integrated in a 3.7 point release?

Olivier, what is your opinion on this ?
Comment 11 Satyam Kandula CLA 2011-08-19 12:10:55 EDT
Created attachment 201811 [details]
Junit test

Junit test for this problem
Comment 12 Satyam Kandula CLA 2011-08-19 12:40:41 EDT
All tests pass with the patch.
Comment 13 Satyam Kandula CLA 2011-08-22 01:37:44 EDT
We were busy with Java 7 support and hence this got left out. Now, this does seem to be a little late for 3.7.1. Added to this, we generally put only regressions and very serious problems into a service release and this doesn't qualify that criteria. Hence, we are targeting this for 3.8M2.
Comment 14 Satyam Kandula CLA 2011-08-23 02:18:20 EDT
Released the patch and the Junit test on HEAD
Comment 15 Nikolay Botev CLA 2011-08-24 20:09:31 EDT
Hi,

Thank you for the quick response and integrating this patch. We look forward to seeing this in the next 3.8 milestone release.
Comment 16 Ayushman Jain CLA 2011-09-12 21:50:39 EDT
Verified for 3.8M2 using build I20110911-2000.
Comment 17 Markus Keller CLA 2011-11-14 06:10:22 EST
*** Bug 363512 has been marked as a duplicate of this bug. ***
Comment 18 elatllat CLA 2011-11-14 08:50:13 EST
(In reply to comment #17)
> *** Bug 363512 has been marked as a duplicate of this bug. ***

link to the latest builds:

http://download.eclipse.org/eclipse/downloads/eclipse3x.php
Comment 19 Satyam Kandula CLA 2011-11-14 08:54:48 EST
(In reply to comment #18)
> (In reply to comment #17)
> > *** Bug 363512 has been marked as a duplicate of this bug. ***
> 
> link to the latest builds:
> 
> http://download.eclipse.org/eclipse/downloads/eclipse3x.php
Did you want to mention something else? I don't understand what you want to tell.
Comment 20 elatllat CLA 2011-11-14 08:59:41 EST
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > *** Bug 363512 has been marked as a duplicate of this bug. ***
> > 
> > link to the latest builds:
> > 
> > http://download.eclipse.org/eclipse/downloads/eclipse3x.php
> Did you want to mention something else? I don't understand what you want to
> tell.

I was just providing a link so that people who have this bug and went it fixed can find something download.
Comment 21 Satyam Kandula CLA 2011-11-14 23:47:23 EST
(In reply to comment #20)
> I was just providing a link so that people who have this bug and went it fixed
> can find something download.
Thank you.