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:\>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