javajava-native-interfacebytecodejava-bytecode-asmjpl

Need help to understand Java Bytecode Instruction


I'm trying to do static analysis of bytecode in Prolog. I'm using the bcel library to get instruction list from a MethodGen. For aload_0, I get 0:aload_0[42](1)

I understand aload_0 is meant to load 0th Local variable. But I'm having a hard time understanding the next bits i.e [42](1). It's also there for other instructions, for eg:

invokespecial[183](3) 8
return[177](1)

Can someone please explain what are those?. Would highly appreciate it!


Solution

  • 42 is the opcode for aload_0. 183 is the opcode for invokespecial. 177 is return and so on. The 8 after invokespecial is probably the 16 bit constant pool index that the instruction uses.

    https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-7.html