This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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

Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 14687

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
I agree. Here's the link:
subject: Understanding the disassembled code - reg.
Similar Threads
string question
Question regarding Init block
How to know which statements execute at compile time and which at runtime
Best Practice for getters and setters
encapsulating an if in a try