Bug 65191 - Can't attach source from folder to JAR [build path]
Summary: Can't attach source from folder to JAR [build path]
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-01 18:02 EDT by Jared Burns CLA
Modified: 2004-06-11 11:23 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 Jared Burns CLA 2004-06-01 18:02:24 EDT
Build 20040529

The dialog to attach source to a JAR allows you to choose a directory. However, I don't get the 
source for my .class files in the JAR.

1. Create a project containing a class with a main method, Hello.java (default package).
2. Create a JAR containing only Hello.class.
3. Double-click Hello.class.
4. A class file editor opens.
5. Click "Change attached source...".
6. In the resulting dialog, choose to add an external directory (bug 65186 prevents you from 
choosing the project with the workspace button) and point to the project containing Hello.java
7. You still get the class file editor. The source file Hello.java is not shown.
Comment 1 Martin Aeschlimann CLA 2004-06-07 09:38:48 EDT
I'm not sure if external folders are supported as source attachment location.
Moving to jdt.core for comments.
If not, please move back so I can fix that the source attachment does not allow
this.

Comment 2 Philipe Mulet CLA 2004-06-08 05:19:02 EDT
Olivier - pls check expectation, no feature to add; we only want to align core 
and ui here.
Comment 3 Olivier Thomann CLA 2004-06-08 11:29:23 EDT
That case works for me. I can get the source of the Hello class pointing to an
external folder.
Comment 4 Olivier Thomann CLA 2004-06-09 15:47:14 EDT
If I put "P" (when my java project is called P), I end up with:

org.eclipse.jdt.internal.core.Assert$AssertionFailedException: Assertion failed;
Source attachment path 'P' for IClasspathEntry must be absolute
at org.eclipse.jdt.internal.core.Assert.isTrue(Assert.java:89)
at org.eclipse.jdt.core.JavaCore.newLibraryEntry(JavaCore.java:2749)
at
org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentBlock.getNewEntry(SourceAttachmentBlock.java:226)
at
org.eclipse.jdt.internal.ui.wizards.buildpaths.SourceAttachmentDialog.getResult(SourceAttachmentDialog.java:89)
at
org.eclipse.jdt.ui.wizards.BuildPathDialogAccess.configureSourceAttachment(BuildPathDialogAccess.java:96)
at
org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$3.widgetSelected(ClassFileEditor.java:270)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2719)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2385)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:334)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:128)
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.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:638)
at org.eclipse.core.launcher.Main.main(Main.java:622)

The wizard should not allow a relative path to be used.

/P doesn't seem to work better. I will investigate this second case.
Comment 5 Olivier Thomann CLA 2004-06-09 17:21:22 EDT
External folders should be supported.
But some validation must be done.
1) The source attachment path must be absolute
2) An external folder is not supposed to be able to point to a folder inside the
workspace.

I tried to debug the case where I put /P as the source attachment path. I don't
know where this is discarded, but I end up with an empty source attachment in
the .classpath file. The source mapper is not even called.

As long as /P means the path to the project location, it should work from my
point of view.

When I click on the Workspace button, only an internal jar or a internal fodler
are expected to be found. The folder representing the project should be a valid
option.

Move back to JDT/UI for addition of validation in these scenarii.
Comment 6 Martin Aeschlimann CLA 2004-06-10 04:59:38 EDT
fixed > 20040610
- You can now select projects
- I added validation to require absolute paths
- I didn't yet added the check if folders are located in the workbench. It is
not so cheap testing that (due to linked resources). Is this validation
essential or is it just a recommendation to use local folders if possible?
Comment 7 Martin Aeschlimann CLA 2004-06-10 05:00:16 EDT
Olivier, see my last question in comment 6
Comment 8 Olivier Thomann CLA 2004-06-10 09:47:29 EDT
No, it works. The path is absolute anyway. It is simply weird that you click on
"External folder" and you can select a folder located inside the workspace.
The remaining issue is in bug 65186. I don't see why /P is discarded. It needs
more investigation.
Comment 9 Dirk Baeumer CLA 2004-06-11 11:16:18 EDT
start verifying...
Comment 10 Dirk Baeumer CLA 2004-06-11 11:23:20 EDT
verified that a external directory can be used to attach the source. Couldn't 
verify the project case due to bug 65186.