ADS

Using Javap Tool For Disassembling Classes

javap is a free tool provided along with Java Development Kit. This free tool is capable of showing the prototypes of methods and constructors in a class. In a simple way it dis assembles class files.







Unlike JavaDoc this javap neither shows the description of each and every method/constructor, class usage nor the package description. It gives the prototype of every method in the class (that belong to the class directly i.e. excluding the inherited ones). It also provides name of the super class.

javap does not show the code of the methods/constructors. It is mainly used for reviewing the methods of the class, especially for those who can grasp the usage by just looking at the prototype. javap takes the whole path of the class (along with package,sub package(s)). The following is a syntax for the javap.

 javap package.subpackage.ClassName

The following is a list of run time arguments that can be passed along with the class.
Usage: javap <options> <classes>

where possible options include:

  -help  --help  -?        Print this usage message

  -version                 Version information

  -v  -verbose             Print additional information

  -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)

  -p  -private             Show all classes and members

  -c                       Disassemble the code

  -s                       Print internal type signatures

  -sysinfo                 Show system informasi (path, size, date, MD5 hash)

                           of class being processed

  -constants               Show static simpulan constants

  -classpath <path>        Specify where to find user class files

  -bootclasspath <path>    Override location of bootstrap class files

Here is a simple example for using the javap tool.
 javap java.lang.String >st.txt

The above command is used to get the details of the String class (only the prototypes) of the methods and constructors. st.txt file stores all the information that is extracted by the javap.
Here is an outlook of the syntax,
 javap classname >file_name.txt
classname refers to the entire path of the class including the package.
file_name refers to the name including the location of the file. The extension need not be txt instead you can go as you like.
> is mandatory.

Subscribe to receive free email updates:

ADS