解释 JVM 方法调用指令
Interpreting JVM method call instructions
我明白下面的指令意味着已经发生了方法调用:
invokestatic:indexbyte1=00 indexbyte2=02
我的理解是找到被调用方法在Constant Pool中的索引,进行位移操作:
00 << 8 + 02
这等于零,这不是常量池索引中的有效条目。我是否误解了所需的计算?
我想了解这是如何手动完成的,所以反编译器帮不上什么忙。
索引未计算为00 << 8 + 02
。引用 the standard:
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.
这意味着指令invokevirtual 00 02
将调用其methodref在常量池中索引(00 << 8) | 02
处的方法,即位置2。记住常量池中的第一个条目的索引为1 , 所以索引 2 实际上指的是池中的第二个条目。
我明白下面的指令意味着已经发生了方法调用:
invokestatic:indexbyte1=00 indexbyte2=02
我的理解是找到被调用方法在Constant Pool中的索引,进行位移操作:
00 << 8 + 02
这等于零,这不是常量池索引中的有效条目。我是否误解了所需的计算?
我想了解这是如何手动完成的,所以反编译器帮不上什么忙。
索引未计算为00 << 8 + 02
。引用 the standard:
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.
这意味着指令invokevirtual 00 02
将调用其methodref在常量池中索引(00 << 8) | 02
处的方法,即位置2。记住常量池中的第一个条目的索引为1 , 所以索引 2 实际上指的是池中的第二个条目。