對內部類引用外部方法變數需用final修飾的理解
阿新 • • 發佈:2018-12-26
Last modified 2015-12-14; size 569 bytes
MD5 checksum d52c1f747d7b708cb19cd659e3d5d9ac
Compiled from "JavaDemo.java"
class JavaDemo$1 extends JavaDemo$Inner
SourceFile: "JavaDemo.java"
EnclosingMethod: #19.#20 // JavaDemo.testInner
InnerClasses:
#6; //class JavaDemo$1
#32= #7 of #19; //Inner=class JavaDemo$Inner of class JavaDemo
minor version: 0
major version: 51
flags: ACC_SUPER
Constant pool:
#1 = Fieldref #6.#21 // JavaDemo$1.this$0:LJavaDemo;
#2 = Methodref #7.#22 // JavaDemo$Inner."<init>":(LJavaDemo;)V
#3 = Fieldref #23.#24 // java/lang/System.out:Ljava/io/PrintStream;
#4 = String #25 // 戴爾
#5 = Methodref #26.#27 // java/io/PrintStream.println:(Ljava/lang/String;)V
#6 = Class #28 // JavaDemo$1
#7 = Class #31 // JavaDemo$Inner
#8 = Utf8 this$0
#9 = Utf8 LJavaDemo;
#10 = Utf8 <init>
#11 = Utf8 (LJavaDemo;)V
#12 = Utf8 Code
#13 = Utf8 LineNumberTable
#14 = Utf8 showName
#15 = Utf8 ()V
#16 = Utf8 SourceFile
#17 = Utf8 JavaDemo.java
#18 = Utf8 EnclosingMethod
#19 = Class #33 // JavaDemo
#20 = NameAndType #34:#15 // testInner:()V
#21 = NameAndType #8:#9 // this$0:LJavaDemo;
#22 = NameAndType #10:#11 // "<init>":(LJavaDemo;)V
#23 = Class #35 // java/lang/System
#24 = NameAndType #36:#37 // out:Ljava/io/PrintStream;
#25 = Utf8 戴爾
#26 = Class #38 // java/io/PrintStream
#27 = NameAndType #39:#40 // println:(Ljava/lang/String;)V
#28 = Utf8 JavaDemo$1
#29 = Utf8
#30 = Utf8 InnerClasses
#31 = Utf8 JavaDemo$Inner
#32 = Utf8 Inner
#33 = Utf8 JavaDemo
#34 = Utf8 testInner
#35 = Utf8 java/lang/System
#36 = Utf8 out
#37 = Utf8 Ljava/io/PrintStream;
#38 = Utf8 java/io/PrintStream
#39 = Utf8 println
#40 = Utf8 (Ljava/lang/String;)V
{
final JavaDemo this$0;
flags: ACC_FINAL, ACC_SYNTHETIC
JavaDemo$1(JavaDemo);
flags:
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: aload_1
2: putfield #1 // Field this$0:LJavaDemo;
5: aload_0
6: aload_1
7: invokespecial #2 // Method JavaDemo$Inner."<init>":(LJavaDemo;)V
10: return
LineNumberTable:
line 12: 0
public void showName();
flags: ACC_PUBLIC
Code:
stack=2, locals=1, args_size=1
0: getstatic #3 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #4 // String 戴爾
5: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 14: 0
line 15: 8
}
MD5 checksum d52c1f747d7b708cb19cd659e3d5d9ac
Compiled from "JavaDemo.java"
class JavaDemo$1 extends JavaDemo$Inner
SourceFile: "JavaDemo.java"
EnclosingMethod: #19.#20 // JavaDemo.testInner
InnerClasses:
#6; //class JavaDemo$1
#32= #7 of #19; //Inner=class JavaDemo$Inner of class JavaDemo
minor version: 0
major version: 51
flags: ACC_SUPER
Constant pool:
#1 = Fieldref #6.#21 // JavaDemo$1.this$0:LJavaDemo;
#2 = Methodref #7.#22 // JavaDemo$Inner."<init>":(LJavaDemo;)V
#3 = Fieldref #23.#24 // java/lang/System.out:Ljava/io/PrintStream;
#4 = String #25 // 戴爾
#5 = Methodref #26.#27 // java/io/PrintStream.println:(Ljava/lang/String;)V
#6 = Class #28 // JavaDemo$1
#7 = Class #31 // JavaDemo$Inner
#8 = Utf8 this$0
#9 = Utf8 LJavaDemo;
#10 = Utf8 <init>
#11 = Utf8 (LJavaDemo;)V
#12 = Utf8 Code
#13 = Utf8 LineNumberTable
#14 = Utf8 showName
#15 = Utf8 ()V
#16 = Utf8 SourceFile
#17 = Utf8 JavaDemo.java
#18 = Utf8 EnclosingMethod
#19 = Class #33 // JavaDemo
#20 = NameAndType #34:#15 // testInner:()V
#21 = NameAndType #8:#9 // this$0:LJavaDemo;
#22 = NameAndType #10:#11 // "<init>":(LJavaDemo;)V
#23 = Class #35 // java/lang/System
#24 = NameAndType #36:#37 // out:Ljava/io/PrintStream;
#25 = Utf8 戴爾
#26 = Class #38 // java/io/PrintStream
#27 = NameAndType #39:#40 // println:(Ljava/lang/String;)V
#28 = Utf8 JavaDemo$1
#29 = Utf8
#30 = Utf8 InnerClasses
#31 = Utf8 JavaDemo$Inner
#32 = Utf8 Inner
#33 = Utf8 JavaDemo
#34 = Utf8 testInner
#35 = Utf8 java/lang/System
#36 = Utf8 out
#37 = Utf8 Ljava/io/PrintStream;
#38 = Utf8 java/io/PrintStream
#39 = Utf8 println
#40 = Utf8 (Ljava/lang/String;)V
{
final JavaDemo this$0;
flags: ACC_FINAL, ACC_SYNTHETIC
JavaDemo$1(JavaDemo);
flags:
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: aload_1
2: putfield #1 // Field this$0:LJavaDemo;
5: aload_0
6: aload_1
7: invokespecial #2 // Method JavaDemo$Inner."<init>":(LJavaDemo;)V
10: return
LineNumberTable:
line 12: 0
public void showName();
flags: ACC_PUBLIC
Code:
stack=2, locals=1, args_size=1
0: getstatic #3 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #4 // String 戴爾
5: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
LineNumberTable:
line 14: 0
line 15: 8
}