image.png 右键,进⼊debug模式
image.png 在下⽅可以观察debug窗⼝
点击箭头朝下的蓝⾊按钮,执⾏下⼀条语句
2、在IDEA中使⽤javap指令对class⽂件进⾏解析
对上⾯这段代码进⾏complie后,会⽣成.class⽂件,⽣成的.class⽂件在out/production⽂件夹下,其中learnJVMdemo是你创建的IDEA项⽬
的名称。
image.png
在IDEA的Terminal输⼊指令
image.png
然后输⼊反编译指令,对class⽂件进⾏反编译
image.png
反编译输⼊的结果是(仔细分析反编译的结果,能看到学习jvm途中遇见的很多⽼朋友,例如常量池、局部变量表、<init>⽅法等):a1234@MacBook-Pro learnJVMdemo % javap -v TestStackFrame.class
Classfile /Users/a1234/IDEA_project/learnJVMdemo/out/production/learnJVMdemo/TestStackFrame.class
Last modified 2020年5⽉21⽇; size 1446 bytes
SHA-256 checksum 5c1b47cc1ffe73348dbbc7c2713bff73502254e51e2e528f33c84315f11f2f17
Compiled from "TestStackFrame.java"
public class TestStackFrame
minor version: 0
major version: 58
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #21 // TestStackFrame
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 5, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
idea debug#7 = Fieldref #8.#9 // java/lang/System.out:Ljava/io/PrintStream;
#8 = Class #10 // java/lang/System
#9 = NameAndType #11:#12 // out:Ljava/io/PrintStream;
#10 = Utf8 java/lang/System
#11 = Utf8 out
#12 = Utf8 Ljava/io/PrintStream;
#13 = String #14 // 这是main即将执⾏
#14 = Utf8 这是main即将执⾏
#15 = Methodref #16.#17 // java/io/PrintStream.println:(Ljava/lang/String;)V #16 = Class #18 // java/io/PrintStream
#17 = NameAndType #19:#20 // println:(Ljava/lang/String;)V
#18 = Utf8 java/io/PrintStream
#19 = Utf8 println
#20 = Utf8 (Ljava/lang/String;)V
#21 = Class #22 // TestStackFrame
#22 = Utf8 TestStackFrame
#23 = Methodref #21.#3 // TestStackFrame."<init>":()V
#24 = Methodref #21.#25 // hod1:()V
#25 = NameAndType #26:#6 // method1:()V
#26 = Utf8 method1
#27 = Class #28 // java/lang/Exception
#28 = Utf8 java/lang/Exception
#29 = Methodref #27.#30 // java/lang/Exception.printStackTrace:()V
#30 = NameAndType #31:#6 // printStackTrace:()V
#31 = Utf8 printStackTrace
#32 = Methodref #16.#33 // java/io/PrintStream.println:()V
#33 = NameAndType #19:#6 // println:()V
#34 = String #35 // 这是main执⾏完毕
#35 = Utf8 这是main执⾏完毕
#36 = String #37 // 这是method1即将执⾏
#37 = Utf8 这是method1即将执⾏
#38 = Methodref #21.#39 // hod2:()V
#39 = NameAndType #40:#6 // method2:()V
#40 = Utf8 method2
#41 = String #42 // 这是method1执⾏完毕
#42 = Utf8 这是method1执⾏完毕
#43 = String #44 // 这是method2即将执⾏
#44 = Utf8 这是method2即将执⾏
#45 = Methodref #21.#46 // hod3:()V
#46 = NameAndType #47:#6 // method3:()V
#47 = Utf8 method3
#48 = String #49 // 这是method2执⾏完毕
#49 = Utf8 这是method2执⾏完毕
#50 = String #51 // 这是method3即将执⾏
#51 = Utf8 这是method3即将执⾏
#52 = String #53 // 这是method3执⾏完毕
#53 = Utf8 这是method3执⾏完毕
#54 = Utf8 Code
#55 = Utf8 LineNumberTable
#56 = Utf8 LocalVariableTable
#57 = Utf8 this
#58 = Utf8 LTestStackFrame;
#59 = Utf8 main
#60 = Utf8 ([Ljava/lang/String;)V
#61 = Utf8 e
#62 = Utf8 Ljava/lang/Exception;
#63 = Utf8 args
#64 = Utf8 [Ljava/lang/String;
#65 = Utf8 tt
#66 = Utf8 StackMapTable
#67 = Class #64 // "[Ljava/lang/String;"
#68 = Utf8 i
#69 = Utf8 I
#70 = Utf8 j
#71 = Utf8 SourceFile
#72 = Utf8 TestStackFrame.java
{
public TestStackFrame();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论