Can't open source files of a source-attached jar

87 views
Skip to first unread message

Yang Zhang

unread,
Jul 26, 2011, 12:23:35 AM7/26/11
to scala-i...@googlegroups.com
I'm wondering if I'm missing something here.

If you create a new project, then download and add
http://repo1.maven.org/maven2/ru/circumflex/circumflex-orm/2.0.3/circumflex-orm-2.0.3.jar,
then attach http://repo1.maven.org/maven2/ru/circumflex/circumflex-orm/2.0.3/circumflex-orm-2.0.3-sources.jar
as the source jar, opening the class files doesn't open the
corresponding source files, even though javap shows that the class
files have debug info.

This is the only library for which I can reproduce this. I'm curious
if anyone knows what's up. I've been poking around with javap and
comparing the jars with other jars that work, but so far have been
unsuccessful at debugging this.

Thanks in advance.

David Bernard

unread,
Jul 26, 2011, 4:33:27 PM7/26/11
to scala-i...@googlegroups.com
Hi,

I did a quick test, the circumflex-orm's classes are compiled without debug info like the filename of the source and the source file doesn't match the classname rules (like in java), so eclipse don't know the sourcefile to open.

I didn't try but I thinks that if you printStackTrace with circumflex class in the stack, you will have "compiled code" instead of the filename and the line.

I hope it helps.

/davidB

Yang Zhang

unread,
Jul 26, 2011, 4:38:29 PM7/26/11
to scala-i...@googlegroups.com
On Tue, Jul 26, 2011 at 1:33 PM, David Bernard
<david.be...@gmail.com> wrote:
> Hi,
> I did a quick test, the circumflex-orm's classes are compiled without debug
> info like the filename of the source and the source file doesn't match the
> classname rules (like in java), so eclipse don't know the sourcefile to
> open.

How did you determine this? I tried inspecting the class files using
javap and I could see the name of the source file as well as the line
number tables. I also tried inspecting the project's pom.xml, and it
doesn't override the default -g:vars parameter to scalac.

> I didn't try but I thinks that if you printStackTrace with circumflex class
> in the stack, you will have "compiled code" instead of the filename and the
> line.

Sorry, I'm having some trouble understanding this sentence.... Mind
elaborating a bit more? I'm mainly interested in being able to jump to
the source definitions of the libraries I'm using from within Eclipse,
as well as setting breakpoints on certain source lines within these
libraries.

> I hope it helps.
> /davidB
>
> On Tue, Jul 26, 2011 at 06:23, Yang Zhang <yangha...@gmail.com> wrote:
>>
>> I'm wondering if I'm missing something here.
>>
>> If you create a new project, then download and add
>>
>> http://repo1.maven.org/maven2/ru/circumflex/circumflex-orm/2.0.3/circumflex-orm-2.0.3.jar,
>> then attach
>> http://repo1.maven.org/maven2/ru/circumflex/circumflex-orm/2.0.3/circumflex-orm-2.0.3-sources.jar
>> as the source jar, opening the class files doesn't open the
>> corresponding source files, even though javap shows that the class
>> files have debug info.
>>
>> This is the only library for which I can reproduce this. I'm curious
>> if anyone knows what's up. I've been poking around with javap and
>> comparing the jars with other jars that work, but so far have been
>> unsuccessful at debugging this.
>>
>> Thanks in advance.
>
>

--
Yang Zhang
http://yz.mit.edu/

David Bernard

unread,
Jul 26, 2011, 4:57:20 PM7/26/11
to scala-i...@googlegroups.com
I'm not an expert...

On Tue, Jul 26, 2011 at 22:38, Yang Zhang <yangha...@gmail.com> wrote:
On Tue, Jul 26, 2011 at 1:33 PM, David Bernard
<david.be...@gmail.com> wrote:
> Hi,
> I did a quick test, the circumflex-orm's classes are compiled without debug
> info like the filename of the source and the source file doesn't match the
> classname rules (like in java), so eclipse don't know the sourcefile to
> open.

How did you determine this? I tried inspecting the class files using
javap and I could see the name of the source file as well as the line
number tables. I also tried inspecting the project's pom.xml, and it
doesn't override the default -g:vars parameter to scalac.

You're right, I miss read. there is the name of the source filename, but in the jar the source file is at the root of the jar and not in the right folder tree (package hierarchie).
So eclipse didn't find source.
eg :
source of ru.circumflex.orm.AliasMapProjection is in <jar>/projection.scala and eclipse search it into  <jar>/ru/circumflex/orm/projection.scala


> I didn't try but I thinks that if you printStackTrace with circumflex class
> in the stack, you will have "compiled code" instead of the filename and the
> line.

Sorry, I'm having some trouble understanding this sentence.... Mind
elaborating a bit more?

forgot it was wrong (in this case, I use this techniques for similar issue with classes genereted by Play!)
 
I'm mainly interested in being able to jump to
the source definitions of the libraries I'm using from within Eclipse,
as well as setting breakpoints on certain source lines within these
libraries.

As a workaround you can try to create directory hierarchy with right path and attach this dir.
If it works, also suggest the circumflew author to generate source archives with the folders.

/davidB

Yang Zhang

unread,
Jul 26, 2011, 5:01:00 PM7/26/11
to scala-i...@googlegroups.com
On Tue, Jul 26, 2011 at 1:57 PM, David Bernard

Hmmm...in general, though, you can't rely on a direct mapping between
source files and (top-level) classes, unlike in Java.

David Bernard

unread,
Jul 27, 2011, 7:56:45 AM7/27/11
to scala-i...@googlegroups.com
I agree +/-. Last year I did some test with eclipse/Idea to name my dir toto.foo.bar instead of toto/foo/bar for java or scala project. And it failed to find sources (for browsing or debug).
(at the end I used toto_foo_bar, see http://dwayneb.free.fr/posts/flat_packages/)

Eclipse assume that source of .class are in the directory layout that map package, because .class only include the filename and not the relative path to sourcedirectory, and because it's the java convention, (ScalaIDE reuse as is this feature). IIRC there is a bug about this into eclipse 'JDT bug tracker.

Note that I don't test the behavior of package object. ;-)

Cheers,

/davidB
Reply all
Reply to author
Forward
0 new messages