Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Understanding the disassembled code - reg. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Understanding the disassembled code - reg." Watch "Understanding the disassembled code - reg." New topic
Author

Understanding the disassembled code - reg.

dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi Friends,

I am trying to understand the code disassembled by the "javap" utility. I have written a "toy" program and disassembled it using

javap -c Analyzer
and i got the following output.
Compiled from "Analyzer.java"
public class Analyzer extends java.lang.Object{
public Analyzer();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>" )V
4: aload_0
5: iconst_0
6: putfield #2; //Field varOne:I
9: return

public int getVarOne();
Code:
0: aload_0
1: getfield #2; //Field varOne:I
4: ireturn

public static void main(java.lang.String[]);
Code:
0: iconst_0
1: istore_1
2: new #3; //class Analyzer
5: dup
6: invokespecial #4; //Method "<init>" )V
9: astore_2
10: aload_2
11: invokevirtual #5; //Method getVarOne )I
14: istore_1
15: getstatic #6; //Field java/lang/System.out:Ljava/io/PrintStream;
18: iload_1
19: invokevirtual #7; //Method java/io/PrintStream.println I)V
22: return

}

Can any body help me to understand the mnemonics "aload_0", "invokespecial", "iconstant", etc., Also it will be helpful for me to have some online references regarding these info.

Thanks in advance!!!
regards,
Dinesh Venkatesan.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You'll find the explanation of the instructions in the Java Virtual Machine's specification.
For example : aload.


[My Blog]
All roads lead to JavaRanch
dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi Christophe,

Thanks much for your reference.

regards,
dinesh Venkatesan
 
GeeCON Prague 2014
 
subject: Understanding the disassembled code - reg.