javap command disassembles java class files. Its output depends on the options used. If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout.
here is the class we test compile the following class:-
package com.javastoreroom.net; public class Add { public static void main(String[] args) { new Add().totalValue(5 , 6); } private void totalValue(int i, int j) { System.out.println("Add two value"); System.out.println("[-------Sum of two value ----------"+(i+j)+"------]"); } }
run javap Add following attribute , method shown:-
C:Desktop Arun> javap Add Compiled from "Add.java" public class com.javastoreroom.net.Add extends java.lang.Object{ public com.javastoreroom.net.Add(); public static void main(java.lang.String[]); }
run javap -c Add command following byte-code are shown :-
Compiled from "Add.java" public class com.javastoreroom.net.Add extends java.lang.Object{ public com.javastoreroom.net.Add(); Code: 0: aload_0 1: invokespecial #8; //Method java/lang/Object."":()V 4: return public static void main(java.lang.String[]); Code: 0: new #1; //class com/javastoreroom/net/Add 3: dup 4: invokespecial #16; //Method " ":()V 7: iconst_5 8: bipush 6 10: invokespecial #17; //Method totalValue:(II)V 13: return }
Try another option just type command javap -help following command shown :-
Usage: javap... where options include: -c Disassemble the code -classpath Specify where to find user class files -extdirs Override location of installed extensions -help Print this usage message -J Pass directly to the runtime system -l Print line number and local variable tables -public Show only public classes and members -protected Show protected/public classes and members -package Show package/protected/public classes and members (default) -private Show all classes and members -s Print internal type signatures -bootclasspath Override location of class files loaded by the bootstrap class loader -verbose Print stack size, number of locals and args for methods If verifying, print reasons for failure
No comments:
Post a Comment