A Java class file format supports an attribute called "source debug extension" (see Java language specification §4.7.11 "TheSourceDebugExtension
attribute").
In JVMs that support this aspect of JVMTI, you can query for this string using jvmtiError GetSourceDebugExtension(jvmtiEnv *, jclass, char **)
.
My question is whether there's a way to use ordinary javac
and the Java language to embed "source debug extension" information in a .class
file. There doesn't appear to be an annotation in the core Java language that would do this (no obvious candidates in the "All Known Implementing Classes" list in the javadoc for java.lang.Annotation
).
That attribute was added by JSR 45 to support debugging in non-Java languages. The JVM itself doesn't use the value of the attribute; it's meant for debugging tools. The final release of that JSR describes the motivation for the SourceDebugExtension
attribute as follows:
SourceDebugExtension Support
Debugger applications frequently need debugging information about the source that exceeds what is delivered by the existing JavaTM Virtual Machine class file attributes (SourceFile, LineNumber, and LocalVariable). This is particularly true for debugging the source of other languages. In a distributed environment side files may not be accessible, the information must be directly associated with the class.
The solution is the addition of a class file attribute which holds a string; The string contains debugging information in a standardized format which allows for evolution and vendor extension.
Given that purpose, it's unlikely that javac would put anything in to that field. There is another StackOverflow question asking what JVM languages use the SMAP attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With