gpt4 book ai didi

java - JVM 常量池条目

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:21:17 26 4
gpt4 key购买 nike

查看在某些类上运行 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com