JVMRS
A Java Virtual Machine implementation in Rust, featuring Cranelift JIT, AOT to native object files, generational GC, and multiple compilation backends.
Why JVMRS?
Compared to HotSpot, OpenJ9, and GraalVM, jvmrs differentiates with Rust-native design and unique capabilities:
| Capability | HotSpot / OpenJ9 / GraalVM | JVMRS |
|---|---|---|
| Language | C++ / Java | Rust – memory safety, zero-cost abstractions |
| JIT backend | C2 / Graal / Eclipse OMR | Cranelift – Rust-native, permissive license |
| AOT output | GraalVM native-image (binary) | Object files (.o) – link with any C toolchain |
| WebAssembly | Limited / experimental | WASM emission – run Java in browsers |
| Java ↔ Rust interop | JNI only | Direct polyglot – shared objects, no JNI |
| Embedded / no_std | Not supported | no_std targets – microcontrollers, bare-metal |
| SIMD | Auto-vectorization | Explicit SIMD – Rust core::arch |
| Embedding | Heavy footprint | C API – embed as a library in any app |
| Truffle-style API | GraalVM proprietary | Open implementation – language-agnostic runtime |
Use jvmrs when you need: embeddable JVM, Java→WASM, Rust/Java interop, AOT to .o files, or a Rust-based JVM for research and tooling.
Installation
Add to your Cargo.toml:
[]
= "0.1"
For optional features (LLVM IR, WebAssembly, etc.):
[]
= { = "0.1", = ["wasm"] }
Quick Start
# Clone and run
# Run example classes (examples/ contains precompiled .class files)
# Or compile your own Java and run
Usage
Run a class
# Run main class (resolves via classpath)
CLI options
| Option | Description |
|---|---|
--aot <output> |
AOT compile class to .o file instead of executing |
--no-jit |
Disable JIT; interpreter-only |
--jit-threshold <n> |
Invocations before JIT compile (default: 100) |
--llvm |
Emit LLVM IR to stdout (requires --features llvm) |
--help, -h |
Show help |
Environment variables
| Variable | Description |
|---|---|
JVMRS_DEBUG |
Enable debug logging |
JVMRS_TRACE |
Enable trace logging |
Examples
# Run with default JIT
# Run without JIT
# AOT compile to object file
# Emit LLVM IR (requires: cargo build --features llvm)
# Custom JIT threshold
Examples
Example Java programs in examples/:
HelloWorld.java
Calculator.java
SimpleMath.java
Running the examples
# Precompiled examples (Minimal, TestGetStatic, TestLdc)
# Or compile and run your own
Rust calling Java (polyglot)
Features
Core
- Class file parser, constant pool, stack-based interpreter
- Generational GC with parallel sweep
- Arrays, strings, inheritance, interfaces
- Reflection –
Interpreter::new_instance,get_field_value,set_field_value,invoke_method,get_object_class - Serialization – Binary format for
HeapObjectandValue(JVRS format)
Compilation
- Cranelift JIT – bytecode-to-native for hot methods
- Tiered compilation – interpreter → baseline → optimized
- AOT – compile to
.ovia cranelift-object - LLVM IR (
--features llvm) – export to LLVM - WebAssembly (
--features wasm) – emit WASM
Optional (feature-gated)
ffi– C API for embeddinginterop– Java/Rust polyglotasync– tokio async I/Osimd– SIMD array opstruffle– GraalVM-style language API
Building
Testing
Documentation
- API Documentation
ARCHITECTURE.md– Design and componentsspec.md– Technical specificationTODO.md– Roadmap
License
Licensed under either of MIT or Apache-2.0 at your option.