class

 

查看class文件结构使用JavaClassViewer工具。

 

1、TestScope类

$ javap -verbose  TestScope.class
Classfile /C:/TestScope.class
  Last modified 2018-7-10; size 327 bytes
  MD5 checksum 251bc20d8ef59d8208e84d7124bbb2b7
  Compiled from "TestScope.java"
public class com.test18.TestScope
  SourceFile: "TestScope.java"
  minor version: 0
  major version: 51
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #3.#13         //  java/lang/Object."":()V
   #2 = Class              #14            //  com/test18/TestScope
   #3 = Class              #15            //  java/lang/Object
   #4 = Utf8               
   #5 = Utf8               ()V
   #6 = Utf8               Code
   #7 = Utf8               LineNumberTable
   #8 = Utf8               test02
   #9 = Utf8               StackMapTable
  #10 = Class              #16            //  java/lang/Throwable
  #11 = Utf8               SourceFile
  #12 = Utf8               TestScope.java
  #13 = NameAndType        #4:#5          //  "":()V
  #14 = Utf8               com/test18/TestScope
  #15 = Utf8               java/lang/Object
  #16 = Utf8               java/lang/Throwable
{
  public com.test18.TestScope();
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."":()V
         4: return
      LineNumberTable:
        line 9: 0

  public void test02();
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=1
         0: goto          6
         3: astore_1
         4: aload_1
         5: athrow
         6: return
      Exception table:
         from    to  target type
             3     4     3   any
      LineNumberTable:
        line 24: 0
        line 22: 3
        line 25: 6
      StackMapTable: number_of_entries = 2
           frame_type = 67 /* same_locals_1_stack_item */
          stack = [ class java/lang/Throwable ]
           frame_type = 2 /* same */

}

 

 

2、OuterB$1.class

$ javap -verbose  OuterB\$1.class
Classfile /C:/OuterB$1.class
  Last modified 2018-7-21; size 478 bytes
  MD5 checksum c9b8d8119df1fd29b9744de774f9ea66
  Compiled from "TestScope.java"
class com.test18.OuterB$1 extends com.test18.OuterA
  SourceFile: "TestScope.java"
  EnclosingMethod: #3.#0                  // com.test18.OuterB
  InnerClasses:
       #6; //class com/test18/OuterB$1
  minor version: 0
  major version: 51
  flags: ACC_SUPER
Constant pool:
   #1 = Fieldref           #6.#19         //  com/test18/OuterB$1.this$0:Lcom/test18/OuterB;
   #2 = Methodref          #7.#20         //  com/test18/OuterA."":()V
   #3 = Class              #21            //  com/test18/OuterB
   #4 = Methodref          #3.#20         //  com/test18/OuterB."":()V
   #5 = Methodref          #3.#22         //  com/test18/OuterB.access$000:(Lcom/test18/OuterB;)I
   #6 = Class              #23            //  com/test18/OuterB$1
   #7 = Class              #26            //  com/test18/OuterA
   #8 = Utf8               this$0
   #9 = Utf8               Lcom/test18/OuterB;
  #10 = Utf8               
  #11 = Utf8               (Lcom/test18/OuterB;)V
  #12 = Utf8               Code
  #13 = Utf8               LineNumberTable
  #14 = Utf8               t
  #15 = Utf8               ()V
  #16 = Utf8               SourceFile
  #17 = Utf8               TestScope.java
  #18 = Utf8               EnclosingMethod
  #19 = NameAndType        #8:#9          //  this$0:Lcom/test18/OuterB;
  #20 = NameAndType        #10:#15        //  "":()V
  #21 = Utf8               com/test18/OuterB
  #22 = NameAndType        #27:#28        //  access$000:(Lcom/test18/OuterB;)I
  #23 = Utf8               com/test18/OuterB$1
  #24 = Utf8
  #25 = Utf8               InnerClasses
  #26 = Utf8               com/test18/OuterA
  #27 = Utf8               access$000
  #28 = Utf8               (Lcom/test18/OuterB;)I
{
  final com.test18.OuterB this$0;
    flags: ACC_FINAL, ACC_SYNTHETIC

  com.test18.OuterB$1(com.test18.OuterB);
    flags:
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: putfield      #1                  // Field this$0:Lcom/test18/OuterB;
         5: aload_0
         6: invokespecial #2                  // Method com/test18/OuterA."":()V
         9: return
      LineNumberTable:
        line 9: 0

  public void t();
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=1
         0: new           #3                  // class com/test18/OuterB
         3: dup
         4: invokespecial #4                  // Method com/test18/OuterB."":()V
         7: invokestatic  #5                  // Method com/test18/OuterB.access$000:(Lcom/test18/OuterB;)I
        10: istore_1
        11: return
      LineNumberTable:
        line 11: 0
        line 12: 11
}

 

 

3、OuterB.class 

Classfile /C:/OuterB.class
  Last modified 2018-7-21; size 465 bytes
  MD5 checksum 6fa96007c1c2abcaa53fdc993e969551
  Compiled from "TestScope.java"
class com.test18.OuterB extends com.test19.TestProtectedClass
  SourceFile: "TestScope.java"
  InnerClasses:
       #3; //class com/test18/OuterB$1
  minor version: 0
  major version: 51
  flags: ACC_SUPER
Constant pool:
   #1 = Fieldref           #6.#20         //  com/test18/OuterB.a:I
   #2 = Methodref          #7.#21         //  com/test19/TestProtectedClass."":()V
   #3 = Class              #22            //  com/test18/OuterB$1
   #4 = Methodref          #3.#23         //  com/test18/OuterB$1."":(Lcom/test18/OuterB;)V
   #5 = Fieldref           #6.#24         //  com/test18/OuterB.o:Ljava/lang/Object;
   #6 = Class              #25            //  com/test18/OuterB
   #7 = Class              #26            //  com/test19/TestProtectedClass
   #8 = Utf8
   #9 = Utf8               InnerClasses
  #10 = Utf8               o
  #11 = Utf8               Ljava/lang/Object;
  #12 = Utf8               
  #13 = Utf8               ()V
  #14 = Utf8               Code
  #15 = Utf8               LineNumberTable
  #16 = Utf8               access$000
  #17 = Utf8               (Lcom/test18/OuterB;)I
  #18 = Utf8               SourceFile
  #19 = Utf8               TestScope.java
  #20 = NameAndType        #27:#28        //  a:I
  #21 = NameAndType        #12:#13        //  "":()V
  #22 = Utf8               com/test18/OuterB$1
  #23 = NameAndType        #12:#29        //  "":(Lcom/test18/OuterB;)V
  #24 = NameAndType        #10:#11        //  o:Ljava/lang/Object;
  #25 = Utf8               com/test18/OuterB
  #26 = Utf8               com/test19/TestProtectedClass
  #27 = Utf8               a
  #28 = Utf8               I
  #29 = Utf8               (Lcom/test18/OuterB;)V
{
  java.lang.Object o;
    flags:

  com.test18.OuterB();
    flags:
    Code:
      stack=4, locals=1, args_size=1
         0: aload_0
         1: invokespecial #2                  // Method com/test19/TestProtectedClass."":()V
         4: aload_0
         5: new           #3                  // class com/test18/OuterB$1
         8: dup
         9: aload_0
        10: invokespecial #4                  // Method com/test18/OuterB$1."":(Lcom/test18/OuterB;)V
        13: putfield      #5                  // Field o:Ljava/lang/Object;
        16: return
      LineNumberTable:
        line 8: 0
        line 9: 4

  static int access$000(com.test18.OuterB);
    flags: ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: getfield      #1                  // Field a:I
         4: ireturn
      LineNumberTable:
        line 8: 0
}

  

 

 

 

 

 

 

 

 

 

 

 

 

  

你可能感兴趣的:(class)