Integer a = 0;
a++;
举个例子,如下:
package com.test19;
public class BugReport<T> {
private T n;
public void error() {
BugReport<Integer> val = new BugReport<Integer>();
val.n = 0;
Integer.toString(val.n++);
}
public static void main(String[] args) {
BugReport.class.getMethods();
}
}
经过反编译后如下:
package com.test19;
public class BugReport<T> {
private T n;
public BugReport() {
}
public void error() {
BugReport var1 = new BugReport();
var1.n = Integer.valueOf(0);
Integer var3 = (Integer)var1.n;
Object var4 = var1.n = Integer.valueOf(((Integer)var1.n).intValue() + 1);
Integer.toString(var3.intValue());
}
public static void main(String[] var0) {
BugReport.class.getMethods();
}
}
生成的class文件格式如下:
Classfile /C:/BugReport.class
Last modified 2018-7-22; size 741 bytes
MD5 checksum 3c3412b5bb98381c1e3035573f40b89c
Compiled from "BugReport.java"
public class com.test19.BugReport<T extends java.lang.Object> extends java.lang.Object
Signature: #22 // <T:Ljava/lang/Object;>Ljava/lang/Object;
SourceFile: "BugReport.java"
minor version: 0
major version: 51
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref #10.#25 // java/lang/Object."<init>":()V
#2 = Class #26 // com/test19/BugReport
#3 = Methodref #2.#25 // com/test19/BugReport."<init>":()V
#4 = Methodref #6.#27 // java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
#5 = Fieldref #2.#28 // com/test19/BugReport.n:Ljava/lang/Object;
#6 = Class #29 // java/lang/Integer
#7 = Methodref #6.#30 // java/lang/Integer.intValue:()I
#8 = Methodref #6.#31 // java/lang/Integer.toString:(I)Ljava/lang/String;
#9 = Methodref #32.#33 // java/lang/Class.getMethods:()[Ljava/lang/reflect/Method;
#10 = Class #34 // java/lang/Object
#11 = Utf8 n
#12 = Utf8 Ljava/lang/Object;
#13 = Utf8 Signature
#14 = Utf8 TT;
#15 = Utf8 <init>
#16 = Utf8 ()V
#17 = Utf8 Code
#18 = Utf8 LineNumberTable
#19 = Utf8 error
#20 = Utf8 main
#21 = Utf8 ([Ljava/lang/String;)V
#22 = Utf8 <T:Ljava/lang/Object;>Ljava/lang/Object;
#23 = Utf8 SourceFile
#24 = Utf8 BugReport.java
#25 = NameAndType #15:#16 // "<init>":()V
#26 = Utf8 com/test19/BugReport
#27 = NameAndType #35:#36 // valueOf:(I)Ljava/lang/Integer;
#28 = NameAndType #11:#12 // n:Ljava/lang/Object;
#29 = Utf8 java/lang/Integer
#30 = NameAndType #37:#38 // intValue:()I
#31 = NameAndType #39:#40 // toString:(I)Ljava/lang/String;
#32 = Class #41 // java/lang/Class
#33 = NameAndType #42:#43 // getMethods:()[Ljava/lang/reflect/Method;
#34 = Utf8 java/lang/Object
#35 = Utf8 valueOf
#36 = Utf8 (I)Ljava/lang/Integer;
#37 = Utf8 intValue
#38 = Utf8 ()I
#39 = Utf8 toString
#40 = Utf8 (I)Ljava/lang/String;
#41 = Utf8 java/lang/Class
#42 = Utf8 getMethods
#43 = Utf8 ()[Ljava/lang/reflect/Method;
{
public com.test19.BugReport();
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public void error();
flags: ACC_PUBLIC
Code:
stack=3, locals=5, args_size=1
0: new #2 // class com/test19/BugReport
3: dup
4: invokespecial #3 // Method "<init>":()V
7: astore_1
8: aload_1
9: iconst_0
10: invokestatic #4 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
13: putfield #5 // Field n:Ljava/lang/Object;
16: aload_1
17: astore_2
18: aload_2
19: getfield #5 // Field n:Ljava/lang/Object;
22: checkcast #6 // class java/lang/Integer
25: astore_3
26: aload_2
27: aload_2
28: getfield #5 // Field n:Ljava/lang/Object;
31: checkcast #6 // class java/lang/Integer
34: invokevirtual #7 // Method java/lang/Integer.intValue:()I
37: iconst_1
38: iadd
39: invokestatic #4 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
42: dup_x1
43: putfield #5 // Field n:Ljava/lang/Object;
46: astore 4
48: aload_3
49: invokevirtual #7 // Method java/lang/Integer.intValue:()I
52: invokestatic #8 // Method java/lang/Integer.toString:(I)Ljava/lang/String;
55: pop
56: return
LineNumberTable:
line 8: 0
line 9: 8
line 10: 16
line 11: 56
public static void main(java.lang.String[]);
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=1, args_size=1
0: ldc_w #2 // class com/test19/BugReport
3: invokevirtual #9 // Method java/lang/Class.getMethods:()[Ljava/lang/reflect/Method;
6: pop
7: return
LineNumberTable:
line 14: 0
line 15: 7
}