The Class-File API, introduced in Java 22 and evolved in JDK 23, is designed for manipulating Java bytecode, specifically targeting developers who work on frameworks, tools, or advanced performance tuning. It aims to reduce reliance on third-party libraries like ASM by providing a more modern, efficient, and type-safe

14m read timeFrom unlogged.io
Post cover image
Table of contents
Understanding Bytecode and Class FilesThe Current Landscape: ASM and Other Libraries such as Byte Buddy or Javassist.The Chicken and Egg Problem: ASM and JDK Version ChallengeWhy not standardize the ASM in JDK itself instead of creating a new API?Class File APIDesign GoalsThe Class File API is built around three main core abstractions: elements, builders, and transformsComprehensive Overview of the ClassFile InterfaceClassFile Structure: An Ad-hoc Tree-Shaped DesignParsing & Modifying Bytecode with the Class File APIPattern Matching and Switch ExpressionsConstant Pool SharingConclusionReferences:

Sort: