Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345928 - Debugger opens *.class file instead of *.java file!
Summary: Debugger opens *.class file instead of *.java file!
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 08:29 EDT by MH CLA
Modified: 2011-05-31 14:48 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MH CLA 2011-05-16 08:29:00 EDT
Build Identifier: M20110210-1200

When I debug an application that has a JAR with other classes from another Eclipse project, and I set breakpoints in the source file (*.java) of this library, Eclipse opens the class file editor (*.class) instead of the java source editor. I also tried to change the "Java source Attachement" in the properties to either the workspace reference or the absolute file path.

Reproducible: Always
Comment 1 Michael Rennie CLA 2011-05-16 11:12:55 EDT
Can you provide an example project or jar that demonstrates the problem?

We fixed a problem a while back where we were incorrectly opening Java files when the class file should have been, see bug 297039.
Comment 2 MH CLA 2011-05-16 12:07:57 EDT
I can't send you our project, alas. I had some progress: I found the configuration "Debug Configurations > <project> > Source! I added the path to the project source there. Now, at least another ".java" Editor pops up. But it isn't editable. And it opens even though there is already this source open in another editor. I notice the icon of the new *.java Editor is a "J" that is not filled. While the usual Java Editor of the same source file is a filled "J". I haven't found help in the manual what the difference is. But I expected the Eclipse debugger to just use my already open source editor with the breakpoint. The breakpoint in the source is detected but the debugger opens this new non filled "J" editor and halts at the same line.
Comment 3 Michael Rennie CLA 2011-05-17 12:14:45 EDT
(In reply to comment #2)
> I can't send you our project, alas.

You can attach any project / lib combo that demonstrates the problem.

> I had some progress: I found the
> configuration "Debug Configurations > <project> > Source! I added the path to
> the project source there. Now, at least another ".java" Editor pops up. But it
> isn't editable. And it opens even though there is already this source open in
> another editor. I notice the icon of the new *.java Editor is a "J" that is not
> filled. While the usual Java Editor of the same source file is a filled "J". I
> haven't found help in the manual what the difference is. But I expected the
> Eclipse debugger to just use my already open source editor with the breakpoint.
> The breakpoint in the source is detected but the debugger opens this new non
> filled "J" editor and halts at the same line.

This sounds like it is opening the .java file from the archive, which is what you want is it not? If you have added the lib source to your source lookup path it will choose that - based on the ordering you specify in the launch configuration - before it will reuse the open editor.
Comment 4 MH CLA 2011-05-18 04:21:59 EDT
I have no *.java files in my JARs - only *.class files! So there is only one *.java Source file which is in the project path of the related JAR. So, no "lib source" to choose from. I have no idea what Eclipse is doing here. What is this editor with the not-filled "J"?
Comment 5 Michael Rennie CLA 2011-05-18 10:03:57 EDT
> What is this editor with the not-filled "J"?

The editor you see is the read-only Java editor, typically you see it when you open source from an archive.

This problem is sounding very similar to what was found in bug 346116.
Comment 6 MH CLA 2011-05-19 05:11:19 EDT
Okay, I narrowed the problem: in the debug configuration's "Source" tab, I had the "File System Directory" entry too the source. After I removed this and added "Java Project" of the referenced source, the debugger halted in the original source editor as expected.

Unfortunately, this is just a workaround, because I want to have file system directory paths! The reason: whenever I close a project, other projects that relate to this closed project can't find the referenced resources. So I changed all my references to other project's sources to file paths instead of Eclipse Java Porjects. Unfortunately, this results in this bug here ...

In conclusion, I would say, the debugger doesn't use the correct source Editor, if the configuration "source" has a "File System Directory" instead of a "Java Project"!
Comment 7 Michael Rennie CLA 2011-05-19 10:34:44 EDT
(In reply to comment #6)
> In conclusion, I would say, the debugger doesn't use the correct source Editor,
> if the configuration "source" has a "File System Directory" instead of a "Java
> Project"!

Thanks for reporting back with more details.

Can you tell me anything about the shape of the directory you point to for your source? Is it read-only? does it contain jars? What is the absolute path of the file that is opened when you do have the directory on the source lookup path?
Comment 8 MH CLA 2011-05-19 14:43:40 EDT
It contains only the *.java source files and nothing else. Of course, it is writable - otherwise I won't be able to edit and save the source files. I don't understand you last question completely. It's a normal file path without any special characters or spaces ("D:\projects\...\java\src\...*.java").
Comment 9 Michael Rennie CLA 2011-05-31 10:25:01 EDT
(In reply to comment #8)
> It contains only the *.java source files and nothing else. Of course, it is
> writable - otherwise I won't be able to edit and save the source files. I don't
> understand you last question completely. It's a normal file path without any
> special characters or spaces ("D:\projects\...\java\src\...*.java").

I had started thinking that maybe this bug was related to bug 346116, but then I re-read:

"So I changed
all my references to other project's sources to file paths instead of Eclipse
Java Porjects. Unfortunately, this results in this bug here ..."

If I understand correctly, you removed the related Java project source lookup entries from the source lookup path of your launch configuration and replaced them with local file system source lookup path entries?

If so, then this is working as designed. You are seeing the external source / read-only editor because you are telling the source director to find source from outside the workspace. You cannot open source from the workspace if the project the source is to be found in is closed.
Comment 10 MH CLA 2011-05-31 14:16:52 EDT
Oh man, why these restrictions? So, to be able to debug in the real source file, I need to reference the source via the workspace path. But Eclipse is much slower (especially at startup and shutdown) when all projects are open. And I also noticed when backing up my workspave folder, it is much larger with all projects open and therefore takes much more space and time to backup. So I close all projects that I don't need to gain memory and time. But then the source are not found. So I changed the source paths to absolute paths to workaround this. But then the debugger just shows this read only editor. :-( Can you understand my point?

So the only "solution" is to leave all my projects open and live with the poor performance and excessive space of the workspace folder. This is really annoying!
Comment 11 Curtis Windatt CLA 2011-05-31 14:34:13 EDT
(In reply to comment #10)
> So the only "solution" is to leave all my projects open and live with the poor
> performance and excessive space of the workspace folder. This is really
> annoying!

Most of the features in the Eclipse IDE require you to be working with projects open in the IDE.  Closing the projects takes away most of the reasons to be using an IDE in the first place.  I don't see anything we can do here.
Comment 12 Michael Rennie CLA 2011-05-31 14:35:58 EDT
(In reply to comment #10)
> Can you understand my point?

To be honest, I don't quite understand. I can see closing unrelated projects (I typically do the same) but I don't see why you would close related projects.

> So the only "solution" is to leave all my projects open and live with the poor
> performance and excessive space of the workspace folder. 

That is correct.

I am going to mark this as worksforme, as the debugger / source lookup is working as designed, and the reported problem is more of a configuration issue.
Comment 13 MH CLA 2011-05-31 14:48:30 EDT
And what about the problem with the slow start/exit and the big workspace? I don't understand why the workspace is so much bigger wehn my projects are open? I always close all my projects before backing up my workspace to avoid having hundreds of megabytes unnecessary waste in there.