Java javap命令(Version-java9)

2019-01-16  本文已影响0人  MicoCube
  -help  --help  -?                输出此用法消息
  -version                         版本信息
  -v  -verbose                     输出附加信息
  -l                               输出行号和本地变量表
  -public                          仅显示公共类和成员
  -protected                       显示受保护的/公共类和成员
  -package                         显示程序包/受保护的/公共类
                                   和成员 (默认)
  -p  -private                     显示所有类和成员
  -c                               对代码进行反汇编
  -s                               输出内部类型签名
  -sysinfo                         显示正在处理的类的
                                   系统信息 (路径, 大小, 日期, MD5 散列)
  -constants                       显示最终常量
  --module <模块>, -m <模块>       指定包含要反汇编的类的模块
  --module-path <路径>             指定查找应用程序模块的位置
  --system <jdk>                   指定查找系统模块的位置
  --class-path <路径>              指定查找用户类文件的位置
  -classpath <路径>                指定查找用户类文件的位置
  -cp <路径>                       指定查找用户类文件的位置
  -bootclasspath <路径>            覆盖引导类文件的位置

GNU 样式的选项可使用 = (而非空白) 来分隔选项名称
及其值。

每个类可由其文件名, URL 或其
全限定类名指定。示例:
   path/to/MyClass.class
   jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class
   java.lang.Object

javap -c -v ./Abc.class 反汇编并输出附加信息

Classfile /Users/micocube/Documents/Utils4j/target/classes/com/coding/asm/test/Abc.class
  Last modified Jan 15, 2019; size 2532 bytes
  MD5 checksum 99abe1aa8dc262de3a2717383298195c
  Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K extends java.lang.Object, V extends java.lang.Object> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K>
  minor version: 0
  major version: 52
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #10                         // com/coding/asm/test/Abc
  super_class: #11                        // java/util/LinkedHashMap
  interfaces: 1, fields: 3, methods: 12, attributes: 2
Constant pool:
   #1 = Fieldref           #10.#71        // com/coding/asm/test/Abc.a:I
   #2 = Fieldref           #10.#72        // com/coding/asm/test/Abc.c:Ljava/util/Map;
   #3 = Methodref          #11.#73        // java/util/LinkedHashMap."<init>":()V
   #4 = Class              #74            // java/util/ArrayList
   #5 = Methodref          #4.#73         // java/util/ArrayList."<init>":()V
   #6 = Fieldref           #75.#76        // java/lang/System.out:Ljava/io/PrintStream;
   #7 = String             #77            // Hello Main!
   #8 = Methodref          #78.#79        // java/io/PrintStream.println:(Ljava/lang/String;)V
   #9 = String             #80            // Hello ASM!
  #10 = Class              #81            // com/coding/asm/test/Abc
  #11 = Class              #82            // java/util/LinkedHashMap
  #12 = Class              #83            // java/lang/Iterable
  #13 = Utf8               a
  #14 = Utf8               I
  #15 = Utf8               b
  #16 = Utf8               D
  #17 = Utf8               ConstantValue
  #18 = Double             1000.01d
  #20 = Utf8               c
  #21 = Utf8               Ljava/util/Map;
  #22 = Utf8               Signature
  #23 = Utf8               Ljava/util/Map<TK;TV;>;
  #24 = Utf8               getA
  #25 = Utf8               ()I
  #26 = Utf8               Code
  #27 = Utf8               LineNumberTable
  #28 = Utf8               LocalVariableTable
  #29 = Utf8               this
  #30 = Utf8               Lcom/coding/asm/test/Abc;
  #31 = Utf8               LocalVariableTypeTable
  #32 = Utf8               Lcom/coding/asm/test/Abc<TK;TV;>;
  #33 = Utf8               setA
  #34 = Utf8               (I)V
  #35 = Utf8               var1
  #36 = Utf8               getC
  #37 = Utf8               ()Ljava/util/Map;
  #38 = Utf8               ()Ljava/util/Map<TK;TV;>;
  #39 = Utf8               setC
  #40 = Utf8               (Ljava/util/Map;)V
  #41 = Utf8               (Ljava/util/Map<TK;TV;>;)V
  #42 = Utf8               <init>
  #43 = Utf8               ()V
  #44 = Utf8               iterator2
  #45 = Utf8               (Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Iterator;
  #46 = Utf8               Ljava/lang/Object;
  #47 = Utf8               var2
  #48 = Utf8               TK;
  #49 = Utf8               TV;
  #50 = Utf8               (TK;TV;)Ljava/util/Iterator;
  #51 = Utf8               iterator
  #52 = Utf8               ()Ljava/util/Iterator;
  #53 = Utf8               ()Ljava/util/Iterator<TK;>;
  #54 = Utf8               compareTo
  #55 = Utf8               (Ljava/lang/Integer;)Ljava/lang/Integer;
  #56 = Utf8               Ljava/lang/Integer;
  #57 = Utf8               (Ljava/lang/Object;)Ljava/lang/Object;
  #58 = Utf8               (TV;)TK;
  #59 = Utf8               get
  #60 = Utf8               ()Ljava/util/List;
  #61 = Utf8               Ljava/util/ArrayList;
  #62 = Utf8               ()Ljava/util/List<Ljava/io/File;>;
  #63 = Utf8               main
  #64 = Utf8               ([Ljava/lang/String;)V
  #65 = Utf8               var0
  #66 = Utf8               [Ljava/lang/String;
  #67 = Utf8               print
  #68 = Utf8               <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/LinkedHashMap<TK;TV;>;Ljava/lang/Iterable<TK;>;
  #69 = Utf8               SourceFile
  #70 = Utf8               Abc.java
  #71 = NameAndType        #13:#14        // a:I
  #72 = NameAndType        #20:#21        // c:Ljava/util/Map;
  #73 = NameAndType        #42:#43        // "<init>":()V
  #74 = Utf8               java/util/ArrayList
  #75 = Class              #84            // java/lang/System
  #76 = NameAndType        #85:#86        // out:Ljava/io/PrintStream;
  #77 = Utf8               Hello Main!
  #78 = Class              #87            // java/io/PrintStream
  #79 = NameAndType        #88:#89        // println:(Ljava/lang/String;)V
  #80 = Utf8               Hello ASM!
  #81 = Utf8               com/coding/asm/test/Abc
  #82 = Utf8               java/util/LinkedHashMap
  #83 = Utf8               java/lang/Iterable
  #84 = Utf8               java/lang/System
  #85 = Utf8               out
  #86 = Utf8               Ljava/io/PrintStream;
  #87 = Utf8               java/io/PrintStream
  #88 = Utf8               println
  #89 = Utf8               (Ljava/lang/String;)V
{
  public int getA();
    descriptor: ()I
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: pop
         2: getstatic     #1                  // Field a:I
         5: ireturn
      LineNumberTable:
        line 15: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public void setA(int);
    descriptor: (I)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aload_0
         1: pop
         2: iload_1
         3: putstatic     #1                  // Field a:I
         6: return
      LineNumberTable:
        line 19: 0
        line 20: 6
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       7     0  this   Lcom/coding/asm/test/Abc;
            0       7     1  var1   I
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       7     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public java.util.Map<K, V> getC();
    descriptor: ()Ljava/util/Map;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: getfield      #2                  // Field c:Ljava/util/Map;
         4: areturn
      LineNumberTable:
        line 23: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #38                          // ()Ljava/util/Map<TK;TV;>;

  public void setC(java.util.Map<K, V>);
    descriptor: (Ljava/util/Map;)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: putfield      #2                  // Field c:Ljava/util/Map;
         5: return
      LineNumberTable:
        line 27: 0
        line 28: 5
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc;
            0       6     1  var1   Ljava/util/Map;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       6     1  var1   Ljava/util/Map<TK;TV;>;
    Signature: #41                          // (Ljava/util/Map<TK;TV;>;)V

  public com.coding.asm.test.Abc();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #3                  // Method java/util/LinkedHashMap."<init>":()V
         4: return
      LineNumberTable:
        line 30: 0
        line 31: 4
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public java.util.Iterator iterator2(K, V);
    descriptor: (Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Iterator;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=3, args_size=3
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 34: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Object;
            0       2     2  var2   Ljava/lang/Object;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       2     1  var1   TK;
            0       2     2  var2   TV;
    Signature: #50                          // (TK;TV;)Ljava/util/Iterator;

  public java.util.Iterator<K> iterator();
    descriptor: ()Ljava/util/Iterator;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 38: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #53                          // ()Ljava/util/Iterator<TK;>;

  public java.lang.Integer compareTo(java.lang.Integer);
    descriptor: (Ljava/lang/Integer;)Ljava/lang/Integer;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aload_1
         1: areturn
      LineNumberTable:
        line 42: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Integer;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public K getA(V);
    descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 46: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Object;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       2     1  var1   TV;
    Signature: #58                          // (TV;)TK;

  public java.util.List<java.io.File> get();
    descriptor: ()Ljava/util/List;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=1
         0: new           #4                  // class java/util/ArrayList
         3: dup
         4: invokespecial #5                  // Method java/util/ArrayList."<init>":()V
         7: astore_1
         8: aload_1
         9: areturn
      LineNumberTable:
        line 50: 0
        line 51: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      10     0  this   Lcom/coding/asm/test/Abc;
            8       2     1  var1   Ljava/util/ArrayList;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0      10     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #62                          // ()Ljava/util/List<Ljava/io/File;>;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #7                  // String Hello Main!
         5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 55: 0
        line 56: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       9     0  var0   [Ljava/lang/String;

  public void print();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #9                  // String Hello ASM!
         5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 59: 0
        line 60: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       9     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       9     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
}
Signature: #68                          // <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/LinkedHashMap<TK;TV;>;Ljava/lang/Iterable<TK;>;
SourceFile: "Abc.java"

javap -p ./Abc.class 显示所有类和成员

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  private static int a;
  private static final double b;
  private java.util.Map<K, V> c;
  public int getA();
  public void setA(int);
  public java.util.Map<K, V> getC();
  public void setC(java.util.Map<K, V>);
  public com.coding.asm.test.Abc();
  public java.util.Iterator iterator2(K, V);
  public java.util.Iterator<K> iterator();
  public java.lang.Integer compareTo(java.lang.Integer);
  public K getA(V);
  public java.util.List<java.io.File> get();
  public static void main(java.lang.String[]);
  public void print();
}

javap -public ./Abc.class 显示类的public成员

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
  public void setA(int);
  public java.util.Map<K, V> getC();
  public void setC(java.util.Map<K, V>);
  public com.coding.asm.test.Abc();
  public java.util.Iterator iterator2(K, V);
  public java.util.Iterator<K> iterator();
  public java.lang.Integer compareTo(java.lang.Integer);
  public K getA(V);
  public java.util.List<java.io.File> get();
  public static void main(java.lang.String[]);
  public void print();
}

javap -protected 显示受保护的/公共的 类和成员

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
  public void setA(int);
  public java.util.Map<K, V> getC();
  public void setC(java.util.Map<K, V>);
  public com.coding.asm.test.Abc();
  public java.util.Iterator iterator2(K, V);
  public java.util.Iterator<K> iterator();
  public java.lang.Integer compareTo(java.lang.Integer);
  public K getA(V);
  public java.util.List<java.io.File> get();
  public static void main(java.lang.String[]);
  public void print();
}


显示类所有可访问修饰符范围大于protected的成员

javap -l ./Abc.class 输出行号和本地变量表

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
    LineNumberTable:
      line 15: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       6     0  this   Lcom/coding/asm/test/Abc;

  public void setA(int);
    LineNumberTable:
      line 19: 0
      line 20: 6
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       7     0  this   Lcom/coding/asm/test/Abc;
          0       7     1  var1   I

  public java.util.Map<K, V> getC();
    LineNumberTable:
      line 23: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       5     0  this   Lcom/coding/asm/test/Abc;

  public void setC(java.util.Map<K, V>);
    LineNumberTable:
      line 27: 0
      line 28: 5
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       6     0  this   Lcom/coding/asm/test/Abc;
          0       6     1  var1   Ljava/util/Map;

  public com.coding.asm.test.Abc();
    LineNumberTable:
      line 30: 0
      line 31: 4
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       5     0  this   Lcom/coding/asm/test/Abc;

  public java.util.Iterator iterator2(K, V);
    LineNumberTable:
      line 34: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       2     0  this   Lcom/coding/asm/test/Abc;
          0       2     1  var1   Ljava/lang/Object;
          0       2     2  var2   Ljava/lang/Object;

  public java.util.Iterator<K> iterator();
    LineNumberTable:
      line 38: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       2     0  this   Lcom/coding/asm/test/Abc;

  public java.lang.Integer compareTo(java.lang.Integer);
    LineNumberTable:
      line 42: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       2     0  this   Lcom/coding/asm/test/Abc;
          0       2     1  var1   Ljava/lang/Integer;

  public K getA(V);
    LineNumberTable:
      line 46: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       2     0  this   Lcom/coding/asm/test/Abc;
          0       2     1  var1   Ljava/lang/Object;

  public java.util.List<java.io.File> get();
    LineNumberTable:
      line 50: 0
      line 51: 8
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0      10     0  this   Lcom/coding/asm/test/Abc;
          8       2     1  var1   Ljava/util/ArrayList;

  public static void main(java.lang.String[]);
    LineNumberTable:
      line 55: 0
      line 56: 8
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       9     0  var0   [Ljava/lang/String;

  public void print();
    LineNumberTable:
      line 59: 0
      line 60: 8
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       9     0  this   Lcom/coding/asm/test/Abc;
}

javap -package ./Abc.class 显示程序包/受保护的/公共类

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
  public void setA(int);
  public java.util.Map<K, V> getC();
  public void setC(java.util.Map<K, V>);
  public com.coding.asm.test.Abc();
  public java.util.Iterator iterator2(K, V);
  public java.util.Iterator<K> iterator();
  public java.lang.Integer compareTo(java.lang.Integer);
  public K getA(V);
  public java.util.List<java.io.File> get();
  public static void main(java.lang.String[]);
  public void print();
}

javap -v/javap -p -v 输出附加信息

Classfile /Users/micocube/Documents/Utils4j/target/classes/com/coding/asm/test/Abc.class
  Last modified Jan 15, 2019; size 2532 bytes
  MD5 checksum 99abe1aa8dc262de3a2717383298195c
  Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K extends java.lang.Object, V extends java.lang.Object> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K>
  minor version: 0
  major version: 52
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #10                         // com/coding/asm/test/Abc
  super_class: #11                        // java/util/LinkedHashMap
  interfaces: 1, fields: 3, methods: 12, attributes: 2
Constant pool:
   #1 = Fieldref           #10.#71        // com/coding/asm/test/Abc.a:I
   #2 = Fieldref           #10.#72        // com/coding/asm/test/Abc.c:Ljava/util/Map;
   #3 = Methodref          #11.#73        // java/util/LinkedHashMap."<init>":()V
   #4 = Class              #74            // java/util/ArrayList
   #5 = Methodref          #4.#73         // java/util/ArrayList."<init>":()V
   #6 = Fieldref           #75.#76        // java/lang/System.out:Ljava/io/PrintStream;
   #7 = String             #77            // Hello Main!
   #8 = Methodref          #78.#79        // java/io/PrintStream.println:(Ljava/lang/String;)V
   #9 = String             #80            // Hello ASM!
  #10 = Class              #81            // com/coding/asm/test/Abc
  #11 = Class              #82            // java/util/LinkedHashMap
  #12 = Class              #83            // java/lang/Iterable
  #13 = Utf8               a
  #14 = Utf8               I
  #15 = Utf8               b
  #16 = Utf8               D
  #17 = Utf8               ConstantValue
  #18 = Double             1000.01d
  #20 = Utf8               c
  #21 = Utf8               Ljava/util/Map;
  #22 = Utf8               Signature
  #23 = Utf8               Ljava/util/Map<TK;TV;>;
  #24 = Utf8               getA
  #25 = Utf8               ()I
  #26 = Utf8               Code
  #27 = Utf8               LineNumberTable
  #28 = Utf8               LocalVariableTable
  #29 = Utf8               this
  #30 = Utf8               Lcom/coding/asm/test/Abc;
  #31 = Utf8               LocalVariableTypeTable
  #32 = Utf8               Lcom/coding/asm/test/Abc<TK;TV;>;
  #33 = Utf8               setA
  #34 = Utf8               (I)V
  #35 = Utf8               var1
  #36 = Utf8               getC
  #37 = Utf8               ()Ljava/util/Map;
  #38 = Utf8               ()Ljava/util/Map<TK;TV;>;
  #39 = Utf8               setC
  #40 = Utf8               (Ljava/util/Map;)V
  #41 = Utf8               (Ljava/util/Map<TK;TV;>;)V
  #42 = Utf8               <init>
  #43 = Utf8               ()V
  #44 = Utf8               iterator2
  #45 = Utf8               (Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Iterator;
  #46 = Utf8               Ljava/lang/Object;
  #47 = Utf8               var2
  #48 = Utf8               TK;
  #49 = Utf8               TV;
  #50 = Utf8               (TK;TV;)Ljava/util/Iterator;
  #51 = Utf8               iterator
  #52 = Utf8               ()Ljava/util/Iterator;
  #53 = Utf8               ()Ljava/util/Iterator<TK;>;
  #54 = Utf8               compareTo
  #55 = Utf8               (Ljava/lang/Integer;)Ljava/lang/Integer;
  #56 = Utf8               Ljava/lang/Integer;
  #57 = Utf8               (Ljava/lang/Object;)Ljava/lang/Object;
  #58 = Utf8               (TV;)TK;
  #59 = Utf8               get
  #60 = Utf8               ()Ljava/util/List;
  #61 = Utf8               Ljava/util/ArrayList;
  #62 = Utf8               ()Ljava/util/List<Ljava/io/File;>;
  #63 = Utf8               main
  #64 = Utf8               ([Ljava/lang/String;)V
  #65 = Utf8               var0
  #66 = Utf8               [Ljava/lang/String;
  #67 = Utf8               print
  #68 = Utf8               <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/LinkedHashMap<TK;TV;>;Ljava/lang/Iterable<TK;>;
  #69 = Utf8               SourceFile
  #70 = Utf8               Abc.java
  #71 = NameAndType        #13:#14        // a:I
  #72 = NameAndType        #20:#21        // c:Ljava/util/Map;
  #73 = NameAndType        #42:#43        // "<init>":()V
  #74 = Utf8               java/util/ArrayList
  #75 = Class              #84            // java/lang/System
  #76 = NameAndType        #85:#86        // out:Ljava/io/PrintStream;
  #77 = Utf8               Hello Main!
  #78 = Class              #87            // java/io/PrintStream
  #79 = NameAndType        #88:#89        // println:(Ljava/lang/String;)V
  #80 = Utf8               Hello ASM!
  #81 = Utf8               com/coding/asm/test/Abc
  #82 = Utf8               java/util/LinkedHashMap
  #83 = Utf8               java/lang/Iterable
  #84 = Utf8               java/lang/System
  #85 = Utf8               out
  #86 = Utf8               Ljava/io/PrintStream;
  #87 = Utf8               java/io/PrintStream
  #88 = Utf8               println
  #89 = Utf8               (Ljava/lang/String;)V
{
  private static int a;
    descriptor: I
    flags: (0x000a) ACC_PRIVATE, ACC_STATIC

  private static final double b;
    descriptor: D
    flags: (0x001a) ACC_PRIVATE, ACC_STATIC, ACC_FINAL
    ConstantValue: double 1000.01d

  private java.util.Map<K, V> c;
    descriptor: Ljava/util/Map;
    flags: (0x0002) ACC_PRIVATE
    Signature: #23                          // Ljava/util/Map<TK;TV;>;

  public int getA();
    descriptor: ()I
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: pop
         2: getstatic     #1                  // Field a:I
         5: ireturn
      LineNumberTable:
        line 15: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public void setA(int);
    descriptor: (I)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aload_0
         1: pop
         2: iload_1
         3: putstatic     #1                  // Field a:I
         6: return
      LineNumberTable:
        line 19: 0
        line 20: 6
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       7     0  this   Lcom/coding/asm/test/Abc;
            0       7     1  var1   I
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       7     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public java.util.Map<K, V> getC();
    descriptor: ()Ljava/util/Map;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: getfield      #2                  // Field c:Ljava/util/Map;
         4: areturn
      LineNumberTable:
        line 23: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #38                          // ()Ljava/util/Map<TK;TV;>;

  public void setC(java.util.Map<K, V>);
    descriptor: (Ljava/util/Map;)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: putfield      #2                  // Field c:Ljava/util/Map;
         5: return
      LineNumberTable:
        line 27: 0
        line 28: 5
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc;
            0       6     1  var1   Ljava/util/Map;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       6     1  var1   Ljava/util/Map<TK;TV;>;
    Signature: #41                          // (Ljava/util/Map<TK;TV;>;)V

  public com.coding.asm.test.Abc();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #3                  // Method java/util/LinkedHashMap."<init>":()V
         4: return
      LineNumberTable:
        line 30: 0
        line 31: 4
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public java.util.Iterator iterator2(K, V);
    descriptor: (Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Iterator;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=3, args_size=3
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 34: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Object;
            0       2     2  var2   Ljava/lang/Object;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       2     1  var1   TK;
            0       2     2  var2   TV;
    Signature: #50                          // (TK;TV;)Ljava/util/Iterator;

  public java.util.Iterator<K> iterator();
    descriptor: ()Ljava/util/Iterator;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 38: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #53                          // ()Ljava/util/Iterator<TK;>;

  public java.lang.Integer compareTo(java.lang.Integer);
    descriptor: (Ljava/lang/Integer;)Ljava/lang/Integer;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aload_1
         1: areturn
      LineNumberTable:
        line 42: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Integer;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;

  public K getA(V);
    descriptor: (Ljava/lang/Object;)Ljava/lang/Object;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=1, locals=2, args_size=2
         0: aconst_null
         1: areturn
      LineNumberTable:
        line 46: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc;
            0       2     1  var1   Ljava/lang/Object;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       2     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
            0       2     1  var1   TV;
    Signature: #58                          // (TV;)TK;

  public java.util.List<java.io.File> get();
    descriptor: ()Ljava/util/List;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=1
         0: new           #4                  // class java/util/ArrayList
         3: dup
         4: invokespecial #5                  // Method java/util/ArrayList."<init>":()V
         7: astore_1
         8: aload_1
         9: areturn
      LineNumberTable:
        line 50: 0
        line 51: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      10     0  this   Lcom/coding/asm/test/Abc;
            8       2     1  var1   Ljava/util/ArrayList;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0      10     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
    Signature: #62                          // ()Ljava/util/List<Ljava/io/File;>;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #7                  // String Hello Main!
         5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 55: 0
        line 56: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       9     0  var0   [Ljava/lang/String;

  public void print();
    descriptor: ()V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #9                  // String Hello ASM!
         5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 59: 0
        line 60: 8
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       9     0  this   Lcom/coding/asm/test/Abc;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0       9     0  this   Lcom/coding/asm/test/Abc<TK;TV;>;
}
Signature: #68                          // <K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/LinkedHashMap<TK;TV;>;Ljava/lang/Iterable<TK;>;
SourceFile: "Abc.java"

javap -c 反汇编

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
    Code:
       0: aload_0
       1: pop
       2: getstatic     #1                  // Field a:I
       5: ireturn

  public void setA(int);
    Code:
       0: aload_0
       1: pop
       2: iload_1
       3: putstatic     #1                  // Field a:I
       6: return

  public java.util.Map<K, V> getC();
    Code:
       0: aload_0
       1: getfield      #2                  // Field c:Ljava/util/Map;
       4: areturn

  public void setC(java.util.Map<K, V>);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #2                  // Field c:Ljava/util/Map;
       5: return

  public com.coding.asm.test.Abc();
    Code:
       0: aload_0
       1: invokespecial #3                  // Method java/util/LinkedHashMap."<init>":()V
       4: return

  public java.util.Iterator iterator2(K, V);
    Code:
       0: aconst_null
       1: areturn

  public java.util.Iterator<K> iterator();
    Code:
       0: aconst_null
       1: areturn

  public java.lang.Integer compareTo(java.lang.Integer);
    Code:
       0: aload_1
       1: areturn

  public K getA(V);
    Code:
       0: aconst_null
       1: areturn

  public java.util.List<java.io.File> get();
    Code:
       0: new           #4                  // class java/util/ArrayList
       3: dup
       4: invokespecial #5                  // Method java/util/ArrayList."<init>":()V
       7: astore_1
       8: aload_1
       9: areturn

  public static void main(java.lang.String[]);
    Code:
       0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
       3: ldc           #7                  // String Hello Main!
       5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       8: return

  public void print();
    Code:
       0: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
       3: ldc           #9                  // String Hello ASM!
       5: invokevirtual #8                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
       8: return
}

其实,javap -c 输出内部javap -v中已经有了

javap -s/javap -p -s ./Abc.class 输出内部类型签名

Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
    descriptor: ()I

  public void setA(int);
    descriptor: (I)V

  public java.util.Map<K, V> getC();
    descriptor: ()Ljava/util/Map;

  public void setC(java.util.Map<K, V>);
    descriptor: (Ljava/util/Map;)V

  public com.coding.asm.test.Abc();
    descriptor: ()V

  public java.util.Iterator iterator2(K, V);
    descriptor: (Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Iterator;

  public java.util.Iterator<K> iterator();
    descriptor: ()Ljava/util/Iterator;

  public java.lang.Integer compareTo(java.lang.Integer);
    descriptor: (Ljava/lang/Integer;)Ljava/lang/Integer;

  public K getA(V);
    descriptor: (Ljava/lang/Object;)Ljava/lang/Object;

  public java.util.List<java.io.File> get();
    descriptor: ()Ljava/util/List;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V

  public void print();
    descriptor: ()V
}

javap -sysinfo/javap -p -sysinfo ./Abc.class 显示正在处理的类的系统信息 (路径, 大小, 日期, MD5 散列)

Classfile /Users/micocube/Documents/Utils4j/target/classes/com/coding/asm/test/Abc.class
  Last modified Jan 15, 2019; size 2532 bytes
  MD5 checksum 99abe1aa8dc262de3a2717383298195c
  Compiled from "Abc.java"
public class com.coding.asm.test.Abc<K, V> extends java.util.LinkedHashMap<K, V> implements java.lang.Iterable<K> {
  public int getA();
  public void setA(int);
  public java.util.Map<K, V> getC();
  public void setC(java.util.Map<K, V>);
  public com.coding.asm.test.Abc();
  public java.util.Iterator iterator2(K, V);
  public java.util.Iterator<K> iterator();
  public java.lang.Integer compareTo(java.lang.Integer);
  public K getA(V);
  public java.util.List<java.io.File> get();
  public static void main(java.lang.String[]);
  public void print();
}

javap -constants/-p -constants ./Abc.class 显示最终常量

C:\Users\user\Desktop>javap -constants JavapTest.class
Compiled from "JavapTest.java"
public class com.method.handler.JavapTest {
  public static final int _P_2 = 2;
  public com.method.handler.JavapTest();
  public static void main(java.lang.String[]);
}


上一篇下一篇

猜你喜欢

热点阅读