Skip to content

A ClassFile parser capable of extracting and loading .class files from Java, Scala, Kotlin and more!

License

Notifications You must be signed in to change notification settings

bbambozzi/ClassParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A ClassFile parser capable of extracting and loading .class files from Java, Scala, Kotlin and more!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages