java - javac 可以提供类的 "source debug extension information"属性吗?

标签 java annotations jvmti

Java 类文件格式支持称为“源调试扩展”的属性(参见 Java language specification §4.7.11 "TheSourceDebugExtension attribute")。

在支持 JVMTI 这方面的 JVM 中,您可以使用 jvmtiError GetSourceDebugExtension(jvmtiEnv *, jclass, char **) 查询此字符串.

我的问题是是否有办法使用普通的javac 和Java 语言将“源调试扩展”信息嵌入到.class 文件中。在核心 Java 语言中似乎没有注释可以执行此操作(javadoc for java.lang.Annotation 中的“所有已知实现类”列表中没有明显的候选对象)。

最佳答案

该属性是由 JSR 45 添加的支持使用非 Java 语言进行调试。 JVM 本身不使用该属性的值;它用于调试工具。 The final release of that JSR描述 SourceDebugExtension 属性的动机如下:

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.

鉴于此目的,javac 不太可能将任何内容放入该字段。还有另一个 StackOverflow 问题问 what JVM languages use the SMAP attribute .

关于java - javac 可以提供类的 "source debug extension information"属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25516850/

相关文章:

java - Web 服务响应包含无效的 XML 字符

java - 迭代 List<> 中包含的 HashMap<> 以获取包含在映射中的数组变量作为 java 中的值

Java 字节码检测 : NullPointerException in reflective call to defineClass

java - JVMTI SuspendThread 和 Javas thread.suspend 有什么区别?

java - 哪个是唯一标识从 Ajax 到 Servlet 请求的客户端状态的最佳选择?

java - 如何禁用浏览器基本身份验证弹出窗口 - Angular 5 + Spring Security

java - Spring AOP 切入点,用于在带有注释的字段上调用方法

java - 在注释处理环境中获取静态初始值设定项

java - Crypt 使用 RESTEasy 通过注释解密 java 对象 ID

Java 附加 API : UnsatisfiedLinkError