How to view a class byte-code file

Source: Internet
Author: User

1. Compiling Java files using Javac

2. Use Javap-verbose to view the class bytecode file

2.1 Use the-g:none or-g:lines option to cancel or request a build linenumbertable

2.2 Use the-g:none or-g:vars option to cancel or request a build localvariabletable

2.3 Example

D:\>javac-g:lines-g:vars Test.java

3. Example:

3.1 Instance Code

 Public class Test {    publicint  getInt () {        int a = 1;         return A;    }}

3.2 Compiling

D:\>javac Test.java

3.3 View class files

D:\&GT;JAVAP-verbose testclassfile/d:/test.classLast modified2016-6-6; Size 243bytes MD5 checksum a140b97d207299f2d645e25fc1552334 Compiled from"Test.java" Public classTest sourcefile:"Test.java"Minor version:0Major Version:51flags:acc_public, Acc_superconstant pool: #1 = methodref #3. #12//java/lang/object. " <init> ":() V#2 = Class #13//Test#3 = Class #14//Java/lang/object#4 = Utf8 <init>   #5 =Utf8 () V #6 =Utf8 Code #7 =Utf8 linenumbertable #8 =Utf8 GetInt #9 =Utf8 () I #10 =Utf8 SourceFile #11 =Utf8 Test.java #Nameandtype = #4: #5//"<init>":() V#13 =Utf8 Test #= Utf8 java/lang/object{ PublicTest (); Flags:acc_public Code:stack=1, Locals=1, args_size=1 0: Aload_01:invokespecial #1//Method java/lang/object. " <init>":() V 4:returnLinenumbertable:line1:0 Public intgetInt (); Flags:acc_public Code:stack=1, locals=2, args_size=1 0: Iconst_11: Istore_12: Iload_13: Ireturn linenumbertable:line4:0 Line5:2}

How to view a class byte-code file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.