SourceFile attribute ignored by jswat?

Michel Schinz <[email protected]> Mon, 23 Feb 2004 17:26:37 +0100
Newsgroups gmane.comp.java.jswat.user
Message-ID <[email protected]>
Hi!

I did a few experiments with jswat in order to understand how it finds
source files corresponding to the class files being debugged, and I
have come to the conclusion that the SourceFile attribute is ignored.

To come to this conclusion, I wrote the following trivial Java file:

  package toto;
  class MyClass {
    public static void main(String[] args) { System.out.println("hi"); }
  }

and saved it in a file called "SomeClass.java". Note that the file
name is *not* the name of the class it contains, which is legal in
Java, as long as the class is not public, which is the case here. I
then compiled this file with javac and tried to debug it using jswat,
with the proper sourcepath. jswat complained that it could not find
the source. Then, I made a symbolic link called "MyClass.java" and
pointing to "SomeClass.java", and restarted jswat. It was then able to
find the source. (A trace of this session is appended to this mail,
for those interested in the details).

This experiment indicates that jswat ignores the "SourceFile"
attribute when looking for source files. I was wondering why this is
so, and would like to know whether this could be changed. As can be
seen with my example, this is annoying for Java (albeit in relatively
unfrequent cases), and really problematic for compilers for other
languages which generate Java class files: some of them do *not*
require that the name of the source file and the name of the generated
class are related.

(This is precisely what happens with the Scala compiler
[http://scala.epfl.ch/], and being the author of the JVM back-end of
this compiler, I'm trying to make it possible to debug Scala programs
with jswat).

Thanks!
Michel.

----------------------------------------------------------------------
[lamppc3 bug-jswat]% tree