对 javap 反编译出来的内容 了解的人来看看。
下面是使用javap 反编译出来的结果,其实我并不想看这个类里面真正的内容,我是想理解 这个类在jvm 里被执行式的情况,所以下面的这段结果,谁能解释一下。
Compiled from MyMain.java
class Singleton extends java.lang.Object {
public static int counter1;
public static int counter2;
public static Singleton getInstance();
static {};
}
Method Singleton()
0 aload_0 // 这句是什么意思。
1 invokespecial #1 <Method java.lang.Object()> // 为什么这里有个 #2 是什么意思
4 getstatic #2 <Field int counter1> // 这句。。。。。
7 iconst_1
8 iadd
9 putstatic #2 <Field int counter1>
12 getstatic #3 <Field int counter2>
15 iconst_1
16 iadd
17 putstatic #3 <Field int counter2>
20 return
Method Singleton getInstance()
0 getstatic #4 <Field Singleton obj>
3 areturn
Method static {}
0 new #5 <Class Singleton>
3 dup
4 invokespecial #6 <Method Singleton()>
7 putstatic #4 <Field Singleton obj>
10 iconst_0
11 putstatic #3 <Field int counter2>
14 return