3.7 KiB
3.7 KiB
RoastVM
A Java Virtual Machine (JVM) implementation written in Rust.
Overview
RoastVM is an educational/experimental JVM implementation that executes Java bytecode. It supports class file parsing, bytecode interpretation, JNI native methods, and includes a boot image system for loading the Java standard library.
Features
- Class File Parsing - Full
.classfile support using deku for binary parsing - Bytecode Interpreter - 200+ JVM instructions implemented
- Object Model - Objects, arrays, monitors, and string interning
- JNI Support - 250+ JNI functions for native method integration
- Boot Image - Load JDK classes from 7z module archives
- Native FFI - Dynamic library loading via libffi
Project Structure
roast-vm/
├── crates/
│ ├── core/ # Main VM implementation
│ │ └── src/
│ │ ├── main.rs # Entry point
│ │ ├── vm.rs # VM controller
│ │ ├── thread.rs # Thread execution
│ │ ├── class_loader.rs # Class loading
│ │ ├── bimage.rs # Boot image reader
│ │ ├── frame/ # Stack frames & interpreter
│ │ ├── class_file/ # Class file parser
│ │ ├── objects/ # Object/array model
│ │ └── native/ # JNI infrastructure
│ │
│ └── roast-vm-sys/ # Native methods (cdylib)
│ └── src/ # JNI implementations
│
├── lib/ # Boot image location
├── data/ # Default classpath
└── docs/ # Detailed documentation
Documentation
Detailed implementation docs are in the docs/ folder:
- Class File Parsing - Binary format, constant pool, attributes
- Frame & Interpreter - Stack frames, opcode dispatch
- Object Management - Objects, arrays, monitors
- JNI - JNIEnv structure, native invocation
- Native/FFI - Library loading, libffi integration
- roast-vm-sys - Native method implementations
- Class Loading - Boot image, classpath, RuntimeClass
Building
cargo build
cargo build --release
cargo test
Running
# Run with default classpath (./data)
cargo run
# Run with custom classpath
cargo run -- /path/to/classes
# With debug logging
RUST_LOG=debug cargo run
Dependencies
| Crate | Purpose |
|---|---|
| deku | Binary class file parsing |
| dashmap | Concurrent maps |
| jni | JNI type definitions |
| libloading | Dynamic library loading |
| libffi | Native function calls |
| sevenz-rust2 | Boot image archives |
| parking_lot | Synchronization |
Status
Early development (v0.2.0). Core class loading, bytecode execution, and JNI are functional. Exception handling and GC are in progress.
Vendor: infernap12