Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adiepenbrock/rjvm
Parse JVM class files with Rust
https://github.com/adiepenbrock/rjvm
jvm parsing rust
Last synced: 3 months ago
JSON representation
Parse JVM class files with Rust
- Host: GitHub
- URL: https://github.com/adiepenbrock/rjvm
- Owner: adiepenbrock
- License: apache-2.0
- Created: 2024-02-25T22:02:36.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-06-08T11:24:10.000Z (7 months ago)
- Last Synced: 2024-09-30T13:04:15.772Z (3 months ago)
- Topics: jvm, parsing, rust
- Language: Rust
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rjvm
`rjvm` is a Rust crate that enables parsing of [JVM class files](https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-2.html#jvms-2.1). 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**.## Getting Started
To integrate `rjvm` into you project, simply add it as a dependency to your `Cargo.toml` file:
```toml
[dependencies]
rjvm = "0.1.0"
```To parse a class file, follow these steps:
- Read the class file into a byte array
- Create a `BufferedReader` from the byte array
- Initialize a mutable `ConstantPool` to store the constant pool entries
- Parse the ClassFile using the `ClassFile::decode` method.```rust
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);
```## Examples
Find some simple examples on how to use `rjvm` in the `examples` directory of this repository.- [`decoding.rs`](https://github.com/adiepenbrock/rjvm/blob/main/examples/decoding.rs): shows an example of how to parse a class file.
- [`instructions.rs`](https://github.com/adiepenbrock/rjvm/blob/main/examples/instructions.rs): shows an example of how to parse a class file and print all methods with their instructions.## Roadmap
- [x] Parse class files with all related elements
- [x] Manage constant pools
- [ ] Read JAR files
- [ ] Write class files