Tooling Advanced

Class-file parsing with the standard API

Use the standard Class-File API for class-file parsing and transformation.

✕ Third-party bytecode parser
ClassReader reader = new ClassReader(
        Files.readAllBytes(classFile));
reader.accept(visitor, 0);
✓ Java 24+
ClassModel model = ClassFile.of().parse(classFile);
model.methods().forEach(method ->
        System.out.println(
                method.methodName().stringValue()));
See a problem with this code? Let us know.
🛡

Supported API

Ships and evolves with the JDK class-file format.

📦

Fewer dependencies

Handles common bytecode tasks without an external library.

🧩

Composable models

Parsing, building, and transformation share one API.

Old Approach
ASM ClassReader
Modern Approach
Class-File API
Since JDK
24
Difficulty
Advanced
Class-file parsing with the standard API
Available

Finalized in JDK 24 (JEP 484, March 2025).

The Class-File API, finalized in JDK 24, provides supported models and transformations for JVM class files. It tracks the class-file format with the JDK and removes the need for third-party libraries in many inspection and generation tasks.