Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.94 KB

README.md

File metadata and controls

44 lines (32 loc) · 1.94 KB

ClassParser: A JVM ClassFile parser ☕

License Java Version Built with Love

Overview

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.

Features

  • 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.

Examples

Give-me-the-bytes Example

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 👾!

Give-me-the-major-version Example

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 ☕

Give-me-'foo'-method-bytecode Example

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 👾!