ClassParser is a general purpose classfile parser for .class files.
It's built on JDK 22 and later, and was created with the goal of testing JEP 447
It grants you access to everything contained in the classfile, including the bytecode.
If you only need the ClassModel, and not the bytecode, the ClassModel API is a better fit for you.
- Simple and straightfoward API: Feed the class the path to the parser. Get what you need. It's that simple.
- Obtain the bytecode: Unlike some others classfile parsers, you can obtain the byte[]s directly from the API.
- Unopinionated: Want the bytecode? Here's the byte[]s.
Path path = Path.of("path/to/file"); // Get the path 📁
ClassModelParser parser = new ClassModelParser(path); // Create the parser 🔍
byte[] mainMethodBytes = parser.findMainMethodBytecode(); // Get the bytecode 👾!
Path path = Path.of("path/to/file"); // Get the path 📁
ClassModelParser parser = new ClassModelParser(path); // Create the parser 🔍
int majorVersion = parser.getMajorVersion(); // Get the major version ☕
Path path = Path.of("path/to/file"); // Get the path 📁
ClassModelParser parser = new ClassModelParser(path); // Create the parser 🔍
byte[] fooBytes = parser.findMethodBytecode("foo"); // Get the bytecode 👾!