Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of viewing class Files by java

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to view class files in java". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "java's method of viewing class files".

1, first use javac to compile the file

2. Use the javap tool to open the edited class file

Javap-verbose SyncTestDemo01.class

The results are as follows:

D:\ idea_workspace\ basic_demo\ out\ production\ basic_demo > javap-verbose SyncTestDemo01.classClassfile / D:/idea_workspace/basic_demo/out/production/basic_demo/SyncTestDemo01.class Last modified 2019-8-25 Size 863 bytes MD5 checksum a021136873e306367959a587cdbadbd6 Compiled from "SyncTestDemo01.java" public class SyncTestDemo01 minor version: 0 major version: 52 flags: ACC_PUBLIC ACC_SUPERConstant pool: # 1 = Methodref # 12.328 / / java/lang/Object. "": () V # 2 = Long 5000l # 4 = Methodref # 29.330 / / java/lang/Thread.sleep: (J) V # 5 = Class # 31 / / java/lang/InterruptedException # 6 = Methodref # 5. Java/lang/InterruptedException.printStackTrace 32 / / java/lang/System.out:Ljava/io/PrintStream: () V # 7 = Fieldref # 33.34 / / # 8 = String # 35 / / synchronized for method # 9 = Methodref # 36.037 / / java/io/PrintStream.println: (Ljava/lang/String ) V # 10 = String # 38 / / synchronized for method no method # 11 = Class # 39 / / SyncTestDemo01 # 12 = Class # 40 / / java/lang/Object # 13 = Utf8 # 14 = Utf8 () V # 15 = Utf8 Code 16 = Utf8 LineNumberTable # 17 = Utf8 LocalVariableTable # 18 = Utf8 this # 19 = Utf8 LSyncTestDemo01 # 20 = Utf8 testSync # 21 = Utf8 e # 22 = Utf8 Ljava/lang/InterruptedException # 23 = Utf8 StackMapTable # 24 = Class # 31 / / java/lang/InterruptedException # 25 = Utf8 test01 # 26 = Utf8 SourceFile # 27 = Utf8 SyncTestDemo01.java # 28 = NameAndType # 13 java/lang/InterruptedException 14 / ": () V # 29 = Class # 41 / / java/lang/Thread # 30 = NameAndType # 42 / sleep: (J) V # 31 = Utf8 java/lang/InterruptedException # 32 = NameAndType # 44 Utf8 java/lang/InterruptedException 14 / / printStackTrace: () V # 33 = Class # 45 / / java/lang/System # 34 = NameAndType # 46:#47 / / out:Ljava/io/PrintStream # 35 = Utf8 synchronized for method # 36 = Class # 48 / / java/io/PrintStream # 37 = NameAndType # 49 println 50 / / Ljava/lang/String ) V # 38 = Utf8 synchronized for method no method # 39 = Utf8 SyncTestDemo01 # 40 = Utf8 java/lang/Object # 41 = Utf8 java/lang/Thread # 42 = Utf8 sleep # 43 = Utf8 (J) V # 44 = Utf8 printStackTrace # 45 = Utf8 Java/lang/System # 46 = Utf8 out # 47 = Utf8 Ljava/io/PrintStream # 48 = Utf8 java/io/PrintStream # 49 = Utf8 println # 50 = Utf8 (Ljava/lang/String;) V {public SyncTestDemo01 () Descriptor: () V 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 1: 0 LocalVariableTable: Start Length Slot Name Signature 050 this LSyncTestDemo01; public synchronized void testSync () Descriptor: () V flags: ACC_PUBLIC, ACC_SYNCHRONIZED Code: stack=2, locals=2 Args_size=1 0: ldc2_w # 2 / / long 5000l 3: invokestatic # 4 / / Method java/lang/Thread.sleep: (J) V 6: goto 149: astore_1 10: aload_1 11: invokevirtual # 6 / / Method java/lang/InterruptedException. PrintStackTrace: () V 14: getstatic # 7 / / Field java/lang/System.out:Ljava/io/PrintStream 17: ldc # 8 / / String synchronized for method 19: invokevirtual # 9 / / Method java/io/PrintStream.println: (Ljava/lang/String ) V 22: return Exception table: from to target type 0 69 Class java/lang/InterruptedException LineNumberTable: line 5: 0 line 8: 6 line 6: 9 line 7: 10 line 9: 14 line 10: 22 LocalVariableTable: Start Length Slot Name Signature 10 4 1 e Ljava/lang/InterruptedException 0 230 this LSyncTestDemo01; StackMapTable: number_of_entries = 2 frame_type = 73 / * same_locals_1_stack_item * / stack = [class java/lang/InterruptedException] frame_type = 4 / * same * / public void test01 () Descriptor: () V flags: ACC_PUBLIC Code: stack=2, locals=1, args_size=1 0: getstatic # 7 / / Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc # 10 / / String synchronized for method no method 5: invokevirtual # 9 / / Method java/io/PrintStream.println: (Ljava/lang/String ) V 8: return LineNumberTable: line 13: 0 line 14: 8 LocalVariableTable: Start Length Slot Name Signature 090 this LSyncTestDemo01;} SourceFile: "SyncTestDemo01.java" so far, I believe you have a deeper understanding of "java's method of viewing class files". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report