User Tools

Site Tools


java:javap

This is an old revision of the document!


JDK's javap tool

What is it

The javap command disassembles one or more class files.
It displays details about the internal structure of Java classes.
It allows us to inspect compiled Java code to better understand how Java works at the bytecode level.

“javap” displays information such as:

  • The names and types of methods in the class.
  • The method signature, which includes the method name, parameter data types, and return type.
  • The byte code of the method, which represents the bytecode instructions used by the JVM.
  • The fields of the class, including their names and types.

When to use it

  • To better understand how Java code works at the bytecode level.
  • To check method signatures and parameter data types and return value types.
  • To check if a class contains the expected fields and methods.
  • To check for errors or performance issues in a program.

Example of usage

Given the following class:

package ro.medjava.generics;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
public class Erasure {
 
    public static void doStuff1(List<String> ls) {
    }
 
    public static <E> void doStuff2(List<E> ls){
    }
 
    public static void main(String[] args) {
        doStuff2(new ArrayList<>(Arrays.asList("Fred")));
    }
}
java/javap.1681300371.txt.gz · Last modified: 2023/07/04 19:36 (external edit)