Code:
stack=2, locals=4, args_size=2
0: iconst_1
1: istore_2
2: new #1 // class pro1/DemoArray
5: dup
6: invokespecial #16 // Method "<init>":()V
9: astore_3
10: aload_3
11: iconst_1
12: invokevirtual #17 // Method test:(I)V
15: getstatic #19 // Field java/lang/System.out:Ljava/io/PrintStream;
18: iload_2
19: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
22: iconst_0
23: istore_3
24: goto 37
27: getstatic #19 // Field java/lang/System.out:Ljava/io/PrintStream;
30: iload_3
31: invokevirtual #25 // Method java/io/PrintStream.println:(I)V
34: iinc 3, 1
37: iload_3
38: bipush 10
40: if_icmplt 27
43: aload_0
44: invokevirtual #30 // Method say:()V
47: return
LineNumberTable:
line 5: 0
line 7: 2
line 8: 10
line 10: 15
line 11: 22
line 12: 27
line 11: 34
line 14: 43
line 15: 47
LocalVariableTable:
Start Length Slot Name Signature
0 48 0 this Lpro1/DemoArray;
0 48 1 a I
2 46 2 b I
10 5 3 demoArray Lpro1/DemoArray;
24 19 3 i I
stack 最大深度
locals 本地变量的个数
args_size 我也不知道
后面接着是操作指令步骤
LineNumberTable
是调试用的信息,左侧的line表示java文件中打断点的行数,右侧表示断点对应的指令,也就是说当执行指令new的时候,你在19行打断点的话会进去
LocalVariableTable
本地变量表
start到start+length表示这个变量在code中的生命周期,如果你定义了一个for循环,里面初始化一个int i你会发现他的start到start+length刚好是他那个for循环的字节码范围
如上面code对应的代码如下
public void test(int a) {
int b=1;
{
DemoArray demoArray = new DemoArray();
demoArray.test(1);
}
System.out.println(b);
say();
}