异常将上下文初始化事件发送到类的侦听器实例_深入浅出JVM性能调优——JVM内存( 五 )


1570: aload_0
1581: invokespecial #1// Method com/lyyzoo/jvm/test01/Person."":()V
1594: aload_0
1605: ldc#2// String 兰博
1617: putfield#3// Field name:Ljava/lang/String;
16210: aload_0
16311: bipush25
16413: putfield#4// Field age:I
16516: return
166【属性表,方法局部变量】
167LineNumberTable:
168line 27: 0
169line 17: 4
170line 18: 10
171line 28: 16
172【本地变量表,方法入参】
173LocalVariableTable:
174StartLengthSlotNameSignature
1750170thisLcom/lyyzoo/jvm/test01/User;
176
177public com.lyyzoo.jvm.test01.User(java.lang.String, int);
178descriptor: (Ljava/lang/String;I)V
179flags: ACC_PUBLIC
180Code:
181stack=2, locals=3, args_size=3
1820: aload_0
1831: invokespecial #1// Method com/lyyzoo/jvm/test01/Person."":()V
1844: aload_0
1855: ldc#2// String 兰博
1867: putfield#3// Field name:Ljava/lang/String;
18710: aload_0
18811: bipush25
18913: putfield#4// Field age:I
19016: aload_0
19117: aload_1
19218: putfield#3// Field name:Ljava/lang/String;
19321: aload_0
19422: iload_2
19523: putfield#4// Field age:I
19626: return
197LineNumberTable:
198line 30: 0
199line 17: 4
200line 18: 10
201line 31: 16
202line 32: 21
203line 33: 26
204LocalVariableTable:
205StartLengthSlotNameSignature
206【可以看出,对象实例方法的第一个参数始终都是 this,这也是为什么我们可以在方法内调用 this 的原因】
2070270thisLcom/lyyzoo/jvm/test01/User;
2080271nameLjava/lang/String;
2090272ageI
210MethodParameters:
211NameFlags
212name
213age
214
215public void printInfo();
216descriptor: ()V
217flags: ACC_PUBLIC
218Code:
219stack=3, locals=1, args_size=1
2200: getstatic#5// Field java/lang/System.out:Ljava/io/PrintStream;
2213: new#6// class java/lang/StringBuilder
2226: dup
2237: invokespecial #7// Method java/lang/StringBuilder."":()V
22410: ldc#8// String name:
22512: invokevirtual #9// Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
22615: aload_0
22716: getfield#3// Field name:Ljava/lang/String;
22819: invokevirtual #9// Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
22922: ldc#10// String , age:
23024: invokevirtual #9// Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
23127: aload_0
23228: getfield#4// Field age:I
23331: invokevirtual #11// Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
23434: invokevirtual #12// Method java/lang/StringBuilder.toString:()Ljava/lang/String;
23537: invokevirtual #13// Method java/io/PrintStream.println:(Ljava/lang/String;)V
23640: return
237LineNumberTable:
238line 37: 0
239line 38: 40
240LocalVariableTable:
241StartLengthSlotNameSignature
2420410thisLcom/lyyzoo/jvm/test01/User;
243
244public static void staticPrintInfo();
245descriptor: ()V
246【访问标志】
247flags: ACC_PUBLIC, ACC_STATIC
248Code:
249stack=2, locals=0, args_size=0
2500: getstatic#5// Field java/lang/System.out:Ljava/io/PrintStream;
2513: ldc#15// String FIELD_NAME:username, AGE_MAX:100
2525: invokevirtual #13// Method java/io/PrintStream.println:(Ljava/lang/String;)V
2538: return
254LineNumberTable:
255line 42: 0
256line 43: 8
257【注意,静态方法第一个参数就不再是 this 了】
258
259
260public void sayHello(java.lang.String);
261descriptor: (Ljava/lang/String;)V
262flags: ACC_PUBLIC
263Code:
264stack=3, locals=2, args_size=2