Implement different stratum for Java Debugger Interface
Asked Answered
P

1

12

In the Java Debugger Interface documentation for the Location class, there's a paragraph discussing the "stratum" of the location. I've been looking around a bit for more detail on how one would go about implementing a new stratum (for, say, Scala or JRuby), but I haven't found much. Can anyone shed some light on the topic?

Paraphrast answered 6/8, 2010 at 13:4 Comment(3)
Have you looked at the spec for JSR-45 (Debugging Support for Other Languages)? jcp.org/en/jsr/detail?id=45Everson
I had not, no. Thanks for the pointer, that helps quite a bit.Paraphrast
I vaguely recall that the class file has an attribute pointing to the source file - have you tried just setting that to a file in another language?Zwieback
D
3

Strata wouldn't really be appropriate for Scala or JRuby as they are compiled directly to bytecodes so the SourceFile and LineNumberTable attributes are enough. Strata are intended for things like JSP which are translated to a Java source file and them compiled. The strata are defined by an source map (SMAP) stored in a SourceDebugExtension attribute. The details of how this all works is part of JSR-45. Another example would be the State Machine Compiler though I don't believe it generates an SMAP. I'm also not sure if javac has an option for embedding the SMAP in the class file. You would then need a separate tool for that.

Depalma answered 17/9, 2010 at 3:39 Comment(1)
In fact, line numbers are insufficiently precise for the bytecode address -> source position mapping for Scala code. A given line of Scala code can easily yield many meaningful breakpoints but current debuggers cannot resolve their source position within such a line.Rampant

© 2022 - 2024 — McMap. All rights reserved.