Crates.io | rjvm |
lib.rs | rjvm |
version | 0.3.0 |
source | src |
created_at | 2024-02-28 14:41:12.514752 |
updated_at | 2024-04-19 20:02:36.966589 |
description | Parse JVM class files with Rust |
homepage | |
repository | https://github.com/adiepenbrock/rjvm |
max_upload_size | |
id | 1156533 |
size | 161,555 |
rjvm
is a Rust crate that enables parsing of JVM class files. This crate supports Java at least up to Java SE 21.
The scope of this crate is not to create a JVM, but to parse and write (in the future) JVM class files.
To integrate rjvm
into you project, simply add it as a dependency to your Cargo.toml
file:
[dependencies]
rjvm = "0.1.0"
To parse a class file, follow these steps:
BufferedReader
from the byte arrayConstantPool
to store the constant pool entriesClassFile::decode
method.let file = include_bytes!("../path/to/your/class/file.class");
let mut buffer = rjvm::decoder::BufferedReader::new(file);
let mut constant_pool = rjvm::types::constants::ConstantPool::new();
let class_file = rjvm::types::elements::ClassFile::decode(&mut buffer, &mut constant_pool);
Find some simple examples on how to use rjvm
in the examples
directory of this repository.
decoding.rs
: shows an example of how to parse a class file.instructions.rs
: shows an example of how to parse a class file and print all methods with their instructions.