GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved
  • ←
  • →

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — Class-file parsing with the standard API | java.evolved

Home / Tooling / Class-file parsing with the standard API
Tooling Advanced

Class-file parsing with the standard API

  • 🐛 Report a code issue
  • 🌐 Report a translation issue
  • 💡 Suggest a new pattern

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

Tooling
Code Comparison
✕ 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()));
Share 𝕏
See a problem with this code? Let us know.
Why the modern way wins
🛡

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
JDK Support
Class-file parsing with the standard API
Available

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

How it works

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.

Related Documentation
ClassFile ↗ Class-File API (JEP 484) ↗
Proof
View proof source ↗
Related patterns
Tooling Advanced

AOT class preloading

Java 8
// Every startup:
// - Load 10,000+ classes
// - Verify bytecode
// - JIT compile hot paths
// Startup: 2-5 seconds
Java 25
// Training run:
$ java -XX:AOTCacheOutput=app.aot \
    -cp app.jar com.App
// Production:
$ java -XX:AOTCache=app.aot \
    -cp app.jar com.App
Hover to see modern ➜
JDK 25+ →
Tooling Advanced

Compact object headers

Java 8
// Default: 128-bit object header
// = 16 bytes overhead per object
// A boolean field object = 32 bytes!
// Mark word (64) + Klass pointer (64)
Java 25
// -XX:+UseCompactObjectHeaders
// 64-bit object header
// = 8 bytes overhead per object
// 50% less header memory
// More objects fit in cache
Hover to see modern ➜
JDK 25+ →
Tooling Intermediate

Multi-file source launcher

Java 8
$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
Java 22+
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java
Hover to see modern ➜
JDK 22+ →
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.