java - JVM 常量池条目

标签 java jvm jvm-bytecode

查看在某些类上运行 javap 的输出,我遇到了以下奇怪的事情:

某些类的常量池包含条目如

#33 = Utf8               Code
#34 = Utf8               LocalVariableTable
#35 = Utf8               StackMapTable
#36 = Utf8               MethodParameters

为什么这些常量会出现在常量池中?

最佳答案

以下常量

#33 = Utf8               Code
#34 = Utf8               LocalVariableTable
#35 = Utf8               StackMapTable
#36 = Utf8               MethodParameters

attributes的名称.

For all attributes, the attribute_name_index must be a valid unsigned 16-bit index into the constant pool of the class. The constant_pool entry at attribute_name_index must be a CONSTANT_Utf8_info structure (§4.4.7) representing the name of the attribute.

您提到的属性具有以下功能:

  • Code 属性包含 Java 虚拟机指令和方法的辅助信息,包括实例初始化方法或类或接口(interface)初始化方法。
  • 调试器可以使用 LocalVariableTable 属性 [...] 在方法执行期间确定给定局部变量的值。
  • StackMapTable 属性用于类型检查验证过程
  • MethodParameters 属性记录有关方法形式参数的信息,例如它们的名称。

关于java - JVM 常量池条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28768333/

相关文章:

java - JAXB - 添加多个@XmlElement

java - Java内存泄漏?用信号量实现哲学家就餐

java - 在运行时更新 JAR

tomcat - 使用 asm 动态生成字节

Java 运行时常量池移除

jvm - 有没有办法在 JVM 堆栈上交换长整型(或 double )值和引用值?

java - 有没有办法覆盖 JPA 中实体子类中的 ID?

java - 同一变量中类的多个实例化

scala - 无法识别的选项 : -Xcext. enabled=true 错误 JVM、JRuby、Scala 和 RubyMine

java - Bipush 在 JVM 中如何工作?