Disassembling Java Bytecode Class Files with 'javap -c -private'

This section provides a tutorial example of how to disassemble Java bytecodes with 'javap -c -private' command. The disassembled codes are JVM execution instructions.

Actually, the main function of "javap" is to disassemble Java bytecodes with the "-c" option. The disassembed codes are execution instructions of JVM (Java Virtual Machine).

Now, let's try "javap -c -private" with the bytecode compiled from Circle.java source code.

C:\herong>javap -private Circle

Compiled from "Circle.java"
public class Circle extends java.lang.Object{
public java.lang.String uom;

private int x;

private int y;

private int r;

public Circle();
  Code:
   0:	aload_0
   1:	invokespecial	#1; //Method java/lang/Object."<init>":()V
   4:	aload_0
   5:	ldc	#2; //String Centimeter
   7:	putfield	#3; //Field uom:Ljava/lang/String;
   10:	aload_0
   11:	iconst_0
   12:	putfield	#4; //Field x:I
   15:	aload_0
   16:	iconst_0
   17:	putfield	#5; //Field y:I
   20:	aload_0
   21:	iconst_1
   22:	putfield	#6; //Field r:I
   25:	return

public void setRadius(int);
  Code:
   0:	aload_0
   1:	iload_1
   2:	putfield	#6; //Field r:I
   5:	return

public void setCenter(int, int);
  Code:
   0:	aload_0
   1:	iload_1
   2:	putfield	#4; //Field x:I
   5:	aload_0
   6:	iload_2
   7:	putfield	#5; //Field y:I
   10:	return

...

private double getArea();
  Code:
   0:	ldc2_w	#18; //double 3.14159d
   3:	aload_0
   4:	getfield	#6; //Field r:I
   7:	i2d
   8:	dmul
   9:	aload_0
   10:	getfield	#6; //Field r:I
   13:	i2d
   14:	dmul
   15:	dreturn

}

Note that:

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

'javap' - The Java Class File Disassembler

 'javap' - Java Disassembler Command and Options

 Listing Public Variables and Methods with 'javap'

 Listing Private Variables and Methods with 'javap -private'

Disassembling Java Bytecode Class Files with 'javap -c -private'

 Looking Up Method Signature with 'javap' Command

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version