Inspecting Bytecode with javap
Decompile class files with javap -c to understand how Java constructs translate to bytecode.
Why Inspect Bytecode?
Understanding bytecode reveals how the JVM actually executes your Java code. It helps debug performance issues, understand compiler optimizations, and verify that synthetic code (lambdas, inner classes) works as expected.
Basic javap Usage
javap ClassName displays the class's public API (method signatures, field declarations). It reads the .class file from the current directory or classpath.
# Compile first:
javac User.java
# Display public API:
javap User
# Output:
# public class User {
# public java.lang.String getName();
# public int getAge();
# }