我在 eclipse 中打开了我的 java 类文件,我对这一行有疑问。
iconst_10
putfield Test.a : int [12]
表示什么[12]
?它是否表示分配的字节数?
我的java代码是
class Test {
public Integer a = 5;
public static void main(String[] args) {
Test t = new Test();
t.a = 4;//This line compiles to the above code.
}
}
这是 javap 代码,但与 eclipse 完全不同
public Test();
Code:
0: aload_0
1: invokespecial #10; //Method java/lang/Object."<init>":()V
4: aload_0
5: iconst_5
6: invokestatic #12; //Method java/lang/Integer.valueOf:(I)Ljava/lang/In
teger;
9: putfield #18; //Field a:Ljava/lang/Integer;
12: return
public static void main(java.lang.String[]);
Code:
0: new #1; //class Test
3: dup
4: invokespecial #26; //Method "<init>":()V
7: astore_1
8: aload_1
9: iconst_4
10: invokestatic #12; //Method java/lang/Integer.valueOf:(I)Ljava/lang/In
teger;
13: putfield #18; //Field a:Ljava/lang/Integer;
16: return
}