How to read the metadata for the mnemonics produced by disassembled Java Bytecode? -


i've never used javap before. explain "code" means in example? shows threes time. mean in context of mnemonics follow on lines below it? indicate there stack frame or something?:

compiled "docfooter.java" public class docfooter extends java.applet.applet {   java.lang.string date;    java.lang.string email;    public docfooter();     code:        0: aload_0               1: invokespecial #1                  // method java/applet/applet."<init>":()v        4: return            public void init();     code:        0: aload_0               1: sipush        500        4: bipush        100        6: invokevirtual #2                  // method resize:(ii)v        9: aload_0              10: aload_0              11: ldc           #3                  // string last_updated       13: invokevirtual #4                  // method getparameter:(ljava/lang/string;)ljava/lang/string;       16: putfield      #5                  // field date:ljava/lang/string;       19: aload_0              20: aload_0              21: ldc           #6                  // string email       23: invokevirtual #4                  // method getparameter:(ljava/lang/string;)ljava/lang/string;       26: putfield      #7                  // field email:ljava/lang/string;       29: return            public void paint(java.awt.graphics);     code:        0: aload_1               1: new           #8                  // class java/lang/stringbuilder        4: dup                   5: invokespecial #9                  // method java/lang/stringbuilder."<init>":()v        8: aload_0               9: getfield      #5                  // field date:ljava/lang/string;       12: invokevirtual #10                 // method java/lang/stringbuilder.append:(ljava/lang/string;)ljava/lang/stringbuilder;       15: ldc           #11                 // string         17: invokevirtual #10                 // method java/lang/stringbuilder.append:(ljava/lang/string;)ljava/lang/stringbuilder;       20: invokevirtual #12                 // method java/lang/stringbuilder.tostring:()ljava/lang/string;       23: bipush        100       25: bipush        15       27: invokevirtual #13                 // method java/awt/graphics.drawstring:(ljava/lang/string;ii)v       30: aload_1              31: aload_0              32: getfield      #7                  // field email:ljava/lang/string;       35: sipush        290       38: bipush        15       40: invokevirtual #13                 // method java/awt/graphics.drawstring:(ljava/lang/string;ii)v       43: return         } 

i looked through spec jvm , didn't find explaining "code:", if turns out overlooked pleased post link section. thanks.

javap tool designed java programmers debug code. not designed consumed tools , there no formal specification output. can , change version version.

that being said, if understand jvm specification , classfile format, it's easy understand output of javap.

also note javap tries make things more java-like, hides or obscures of details of bytecode. example, outputs java style method signatures, doesn't necessary reflect in bytecode (and hides synthetic parameters).

if want see closer bytecode is, still human readable, i'd recommend krakatau disassembler (disclosure, wrote it). there lot of other tools viewing bytecode out there, , they're better javap (it's not hard better javap).

furthermore, line numbers (0:),

the line number offset of instruction in bytecode. starts @ 0, , instructions either 1 or 3 bytes. see jvm spec details.

what different sections mean (public void init() followed code: on next line), , #[number] , comments mean?

that shows each method in class, javap-mangled java style method signature. followed textual representation of each instruction in method's bytecode. again, see jvm spec details.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -