I understand that the instruction below means a method call has taken place:
invokestatic:indexbyte1=00 indexbyte2=02
My understanding is that to find the index in the Constant Pool of the method being called, the bit shift operation is performed:
00 << 8 + 02
This equals to zero, which is not a valid entry in the Constant Pool index. Am I misunderstanding the calculation required?
I would like to understand how this is done manually, so a decompiler will not help.
The index is not calculated as 00 << 8 + 02
. To quote 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.
This means that the instruction invokevirtual 00 02
will invoke the method whose methodref is at index (00 << 8) | 02
in the constantpool, i.e., at position 2. Remember that the first entry in the constantpool has index 1, so index 2 actually refers to the second entry of the pool.