This is a modern Java classfile manipulation and analysis library. This library is a modern replacement for ASM, extracted from the latest implementation of JDK and backport to Java 17.
Maven:
<dependency>
<groupId>org.glavo</groupId>
<artifactId>classfile</artifactId>
<version>0.5.0</version>
</dependency>
Gradle:
implementation("org.glavo:classfile:0.5.0")
- Tutorial: The best way to learn how to use the Class-File API;
- Javadoc: Documentation for the current release;
- Examples: Some examples showing the usage of Class-File API;
- JDK Enhancement Proposal: The JEP for Class-File API.
This library is extracted from OpenJDK 23 and renamed package jdk.internal.classfile
to org.glavo.classfile
.
Since the Class-File API is still in preview, this library may also undergo breaking changes until the Class-File API is generally available.
In order to be compatible with Java 17, this library also copies some new APIs in Java 20/21:
java.lang.reflect.AccessFlag
->org.glavo.classfile.AccessFlag
java.lang.reflect.ClassFileFormatVersion
->org.glavo.classfile.ClassFileFormatVersion
java.lang.constant.ModuleDesc
->org.glavo.classfile.constant.ModuleDesc
java.lang.constant.PackageDesc
->org.glavo.classfile.constant.PackageDesc
Since the Class-File API is still in preview, it is not yet stable
Here is the change log.
If you encounter problems when using this library, please feed back through issue.
If you want to discuss the design of the Class-File API, please go to the Class-File API mailing list (classfile-api-dev@openjdk.org) for discussion.