Java字节码中"GOTO"后面的数字是多少?
What is the number after "GOTO" in Java bytecode?
Java 版本:1.8.0_73-b02 64 位
为什么命令GOTO 10
的字节码是A7 FF F7
?
A7
是否对应goto
,FF F7
是否对应10
?
为什么 A7 FF F7
是 GOTO 10
?
这两个字节标识下一条预期指令的内存地址。看看这个 bytecode listing:
中对 GOTO 的描述
goes to another instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)
或者,在 official javadoc
中查看此处
The unsigned bytes branchbyte1 and branchbyte2 are used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of this goto instruction. The target address must be that of an opcode of an instruction within the method that contains this goto instruction.
Java 版本:1.8.0_73-b02 64 位
为什么命令GOTO 10
的字节码是A7 FF F7
?
A7
是否对应goto
,FF F7
是否对应10
?
为什么 A7 FF F7
是 GOTO 10
?
这两个字节标识下一条预期指令的内存地址。看看这个 bytecode listing:
中对 GOTO 的描述goes to another instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 + branchbyte2)
或者,在 official javadoc
中查看此处The unsigned bytes branchbyte1 and branchbyte2 are used to construct a signed 16-bit branchoffset, where branchoffset is (branchbyte1 << 8) | branchbyte2. Execution proceeds at that offset from the address of the opcode of this goto instruction. The target address must be that of an opcode of an instruction within the method that contains this goto instruction.