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
).
-g:source
? – Longhandjavac
manpage where it describes the-g
option, I think that just embeds the source file name. That seems to be what happened when I ran a test using$ javac -g:source Test.java && javap -v Test.class
. – EddoSourceDebugExtension
, though, and I thought that might have been it. – Longhand