gpt4 book ai didi

java - ASM 字节码操作 - istore 和 istore_

转载 作者:太空宇宙 更新时间:2023-11-04 06:30:07 25 4
gpt4 key购买 nike

作为documentation说:

public interface Opcodes

Defines the JVM opcodes, access flags andarray type codes. This interface does not define all the JVM opcodesbecause some opcodes are automatically handled. For example, the xLOADand xSTORE opcodes are automatically replaced by xLOAD_n and xSTORE_nopcodes when possible. The xLOAD_n and xSTORE_n opcodes are thereforenot defined in this interface. Likewise for LDC, automaticallyreplaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and JSR_W.

问题:

如果我有两个几乎相同的 .class 文件 - 一个使用 istore_<n>和一个istore具有显式操作数。 Asm 总是会告诉(ClassReader 和 ClassVisitor)有 istore具有显式操作数。我想使用 asm 但我需要了解这些差异。使用asm可以获得任何指令的真实操作码吗?

最佳答案

ASM 的 ClassWriter 将使用最有效的 ISORE 操作码。如果输出 ISTORE 1,ASM 将输出 ISTORE_1。

因此,ClassReader 会将操作码“解构”为通用形式,隐藏其原始形式。通常可以安全地假设 ISTORE 1 最初是 ISTORE_1,但在其他情况下,ASM 会丢失原始字节码的实际形式。如果您想按原样检查原始字节码,您可能需要使用 javassist 。

关于java - ASM 字节码操作 - istore 和 istore_<n>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26225263/

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