This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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 ""
public class Analyzer extends java.lang.Object{
public Analyzer();
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();
0: aload_0
1: getfield #2; //Field varOne:I
4: ireturn

public static void main(java.lang.String[]);
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!!!
Dinesh Venkatesan.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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.

dinesh Venkatesan
Have you checked out Aspose?
subject: Understanding the disassembled code - reg.
It's not a secret anymore!