JVM学习-javap解析Class文件

C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -version JavapTest.class 1.8.0_131 Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); int getNum(int); protected char showGender(); public void showInfo(); static {}; } // -public 显示公共信息 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -public JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); public void showInfo(); } // -protected C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -protected JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); protected char showGender(); public void showInfo(); } // -private || -p 大于或等于private权限 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -private JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { private int num; boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); private com.chapter09.JavapTest(boolean); private void methodPrivate(); int getNum(int); protected char showGender(); public void showInfo(); static {}; } // -package 显示非私有的信息 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -package JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); int getNum(int); protected char showGender(); public void showInfo(); static {}; } // -sysinfo C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -sysinfo JavapTest.class Classfile /C:/Users/Administrator/IdeaProjects/jvm/target/classes/com/chapter09/JavapTest.class //字节码文件路径 Last modified 2024-5-27; size 1348 bytes //日期 MD5 checksum 85dc41e7e2e7128d8899b5d131d7975f //MD5散列 Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); int getNum(int); protected char showGender(); public void showInfo(); static {}; } // -constants C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -constants JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS = 1; public com.chapter09.JavapTest(); int getNum(int); protected char showGender(); public void showInfo(); static {}; } // -s 输出内部类型签名 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -s JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; descriptor: Z protected char gender; descriptor: C public java.lang.String info; descriptor: Ljava/lang/String; public static final int COUNTS; descriptor: I public com.chapter09.JavapTest(); descriptor: ()V int getNum(int); descriptor: (I)I protected char showGender(); descriptor: ()C public void showInfo(); descriptor: ()V static {}; descriptor: ()V } // -l 输出行号和本地变量表 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -l JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); LineNumberTable: line 20: 0 line 18: 4 line 20: 10 LocalVariableTable: Start Length Slot Name Signature 0 11 0 this Lcom/chapter09/JavapTest; int getNum(int); LineNumberTable: line 26: 0 LocalVariableTable: Start Length Slot Name Signature 0 7 0 this Lcom/chapter09/JavapTest; 0 7 1 i I protected char showGender(); LineNumberTable: line 29: 0 LocalVariableTable: Start Length Slot Name Signature 0 5 0 this Lcom/chapter09/JavapTest; public void showInfo(); LineNumberTable: line 32: 0 line 33: 3 line 34: 30 LocalVariableTable: Start Length Slot Name Signature 0 31 0 this Lcom/chapter09/JavapTest; 3 28 1 i I static {}; LineNumberTable: line 15: 0 line 16: 3 LocalVariableTable: Start Length Slot Name Signature } // -c 对代码进行反编译 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -l JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); LineNumberTable: line 20: 0 line 18: 4 line 20: 10 LocalVariableTable: Start Length Slot Name Signature 0 11 0 this Lcom/chapter09/JavapTest; int getNum(int); LineNumberTable: line 26: 0 LocalVariableTable: Start Length Slot Name Signature 0 7 0 this Lcom/chapter09/JavapTest; 0 7 1 i I protected char showGender(); LineNumberTable: line 29: 0 LocalVariableTable: Start Length Slot Name Signature 0 5 0 this Lcom/chapter09/JavapTest; public void showInfo(); LineNumberTable: line 32: 0 line 33: 3 line 34: 30 LocalVariableTable: Start Length Slot Name Signature 0 31 0 this Lcom/chapter09/JavapTest; 3 28 1 i I static {}; LineNumberTable: line 15: 0 line 16: 3 LocalVariableTable: Start Length Slot Name Signature } C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -c JavapTest.class Compiled from "JavapTest.java" public class com.chapter09.JavapTest { boolean flag; protected char gender; public java.lang.String info; public static final int COUNTS; public com.chapter09.JavapTest(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: aload_0 5: ldc #2 // String java 7: putfield #3 // Field info:Ljava/lang/String; 10: return int getNum(int); Code: 0: aload_0 1: getfield #5 // Field num:I 4: iload_1 5: iadd 6: ireturn protected char showGender(); Code: 0: aload_0 1: getfield #6 // Field gender:C 4: ireturn public void showInfo(); Code: 0: bipush 10 2: istore_1 3: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream; 6: new #8 // class java/lang/StringBuilder 9: dup 10: invokespecial #9 // Method java/lang/StringBuilder."<init>":()V 13: aload_0 14: getfield #3 // Field info:Ljava/lang/String; 17: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 20: iload_1 21: invokevirtual #11 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder; 24: invokevirtual #12 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; 27: invokevirtual #13 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 30: return static {}; Code: 0: ldc #14 // String www.lotus.com 2: astore_0 3: return } // -v 显示最全的字节码反编译数据 C:\Users\Administrator\IdeaProjects\jvm\target\classes\com\chapter09>javap -v JavapTest.class Classfile /C:/Users/Administrator/IdeaProjects/jvm/target/classes/com/chapter09/JavapTest.class //位置 Last modified 2024-5-27; size 1348 bytes //日期,大小 MD5 checksum 85dc41e7e2e7128d8899b5d131d7975f //MD5散列值 Compiled from "JavapTest.java" public class com.chapter09.JavapTest minor version: 0 //副版本号 major version: 52 //主版本号 flags: ACC_PUBLIC, ACC_SUPER //访问标识 Constant pool: #1 = Methodref #16.#46 // java/lang/Object."<init>":()V #2 = String #47 // java #3 = Fieldref #15.#48 // com/chapter09/JavapTest.info:Ljava/lang/String; #4 = Fieldref #15.#49 // com/chapter09/JavapTest.flag:Z #5 = Fieldref #15.#50 // com/chapter09/JavapTest.num:I #6 = Fieldref #15.#51 // com/chapter09/JavapTest.gender:C #7 = Fieldref #52.#53 // java/lang/System.out:Ljava/io/PrintStream; #8 = Class #54 // java/lang/StringBuilder #9 = Methodref #8.#46 // java/lang/StringBuilder."<init>":()V #10 = Methodref #8.#55 // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; #11 = Methodref #8.#56 // java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder; #12 = Methodref #8.#57 // java/lang/StringBuilder.toString:()Ljava/lang/String; #13 = Methodref #58.#59 // java/io/PrintStream.println:(Ljava/lang/String;)V #14 = String #60 // www.lotus.com #15 = Class #61 // com/chapter09/JavapTest #16 = Class #62 // java/lang/Object #17 = Utf8 num #18 = Utf8 I #19 = Utf8 flag #20 = Utf8 Z #21 = Utf8 gender #22 = Utf8 C #23 = Utf8 info #24 = Utf8 Ljava/lang/String; #25 = Utf8 COUNTS #26 = Utf8 ConstantValue #27 = Integer 1 #28 = Utf8 <init> #29 = Utf8 ()V #30 = Utf8 Code #31 = Utf8 LineNumberTable #32 = Utf8 LocalVariableTable #33 = Utf8 this #34 = Utf8 Lcom/chapter09/JavapTest; #35 = Utf8 (Z)V #36 = Utf8 methodPrivate #37 = Utf8 getNum #38 = Utf8 (I)I #39 = Utf8 i #40 = Utf8 showGender #41 = Utf8 ()C #42 = Utf8 showInfo #43 = Utf8 <clinit> #44 = Utf8 SourceFile #45 = Utf8 JavapTest.java #46 = NameAndType #28:#29 // "<init>":()V #47 = Utf8 java #48 = NameAndType #23:#24 // info:Ljava/lang/String; #49 = NameAndType #19:#20 // flag:Z #50 = NameAndType #17:#18
上一篇:系统安全设计规范(Word原件@附软件所有资料)


下一篇:2024最新智能优化算法:常春藤算法(Ivy algorithm,LVYA)求解23个函数,提供MATLAB代码