Disassembling Java Classes - Java Tutorials

Ads
 

Disassembling Java Classes - Java Tutorials

disassembling java classes

disassembling java classes

Disassembling Java Classes

To Disassemble a class file in Java there is a tool called javap. This Disassembling tool prints outs the details of the class like, methods, package, protected, public. When you wish to disassemble any class of java. first compile them using javac then call the javap Class Name.Consider the example given below

DisassesmleExample.java

public class DisassesmleExample {
	public int add(int x, int y) {
		return x + y;
	}

	public int substract(int x, int y) {
		return x - y;
	}

	public int multiply(int x, int y) {
		return x * y;
	}
}

Now Compile the aboove class using javac

C:\Java Test>javac DisassesmleExample.java

Now run it using javap as

C:\Java Test>javap DisassesmleExample
Compiled from "DisassesmleExample.java"
public class DisassesmleExample extends java.lang.Object{
public DisassesmleExample();
public int add(int, int);
public int substract(int, int);
public int multiply(int, int);
}

There are many available with this disassembler  tool they are. For example if you use javap -c DisassesmleExample. This will disassemble all the code, -l it will print line number and local variable. with -package It will show package/ public/protected classes and members. To see more option open your command prompt go to the java/bin directory and then type javap - help it will print all the option of javap.

Ads

Ads