MokaPot is a Rust library for working with JVM bytecode. You can use it to parse, inspect, and change Java class files.
Main features:
- Parse JVM bytecode
- Work with an intermediate representation (MokaIR)
- Build custom tools for JVM bytecode
- Includes documentation and examples
To add MokaPot to your project, run:
cargo add mokapot
To use the latest commit from GitHub:
cargo add --git https://github.com/henryhchchc/mokapot.git mokapot
cargo update
use mokapot::jvm::class::Class;
use std::fs::File;
fn parse_class_file(path: &str) -> Result<Class, Box<dyn std::error::Error>> {
let mut file = File::open(path)?;
let class = Class::from_reader(&mut file)?;
Ok(class)
}
See the examples directory for more code samples.
MokaIR is an intermediate representation of JVM bytecode in this library. See docs/MokaIR.md for details.
Requirements:
- Rust (latest stable)
- JDK (latest release, for compiling Java source files as test data)
To build and test:
cargo build --all-features
cargo test --all-features
See docs/CONTRIBUTING.md for how to contribute.
MIT License. See LICENSE for details.