Missing instruction number in javap output

Whenever I try to understand the disassembly code of a compiled Java file, I wonder why some instruction numbers are missing

A small example:

I disassembled ($javap - C HelloWorld) a simple HelloWorld class This is the output:

Compiled from "HelloWorld.java"
public class HelloWorld {
  public HelloWorld();
    Code:
       0: aload_0       
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: return        

  public static void main(java.lang.String[]);
    Code:
       0: getstatic     #2                  // Field java/lang/System.out:Ljava/io/PrintStream;
       3: ldc           #3                  // String Hello World!
       5: invokevirtual #4                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       8: return        
}

As you can see, instructions 3 and 4 in the constructor and some instructions in the main method are missing

Does anyone know why these command numbers are missing? Are there any bytecode instructions hidden for some reason?

Solution

"Vulnerability" is the parameter of the current instruction. See Java virtual machine specification It contains the complete bytecode list in Chapter 6

For example, both invokevirtual and invokespecial take two parameters, so the next opcode will be found after three bytes In both cases, parameters (indexbyte1 and indexbyte2) are required to calculate the position in the constant pool (indexbyte1 < 8) | indexbyte2). Javap looks up these values for you, which are references in the comments after the actual instruction

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>