1 回答
TA贡献1799条经验 获得超6个赞
仅说一下我认为比较重要的地方, 如果你去看java 字节码, 会看到这种东西:
279: invokevirtual #127 // Method java/lang/Throwable.addSuppressed:Ljava/lang/Throwable;)V
127 即代表 此class中的一个常量池元素, 如果你去看jvm spec7:
invokevirtual ... Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the run-time constant pool of the current class (§2.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The run-time constant pool item at that index must be a symbolic reference to a method (§5.1), which gives the name and descriptor (§4.3.3) of the method as well as a symbolic reference to the class in which the method is to be found.
简单说, jvm正是使用 常量池元素 "Method java/lang/Throwable.addSuppressed:Ljava/lang/Throwable;)V" 找到需要调用的 class和方法.
添加回答
举报