39 releases (breaking)
Uses new Rust 2024
| new 0.35.0 | Nov 5, 2026 |
|---|---|
| 0.33.0 | Aug 19, 2026 |
| 0.32.1 | Jul 27, 2026 |
| 0.30.0 | Mar 23, 2026 |
| 0.12.0 | Nov 29, 2024 |
#501 in Audio
164 downloads per month
Used in 8 crates
(4 directly)
11MB
256K
SLoC
Ristretto VM
Ristretto VM is a Java Virtual Machine implementation written in pure Rust. It executes Java bytecode by interpreting class files loaded through the Ristretto classloader and embeds the JDK Java compiler.
Features
- Standard runtime classes backed by LTS versions of AWS Corretto.
- Flexible class loading from directories, JARs, JMODs, JImage files, and URLs.
- Built-in support for reading, writing, and strictly verifying Java bytecode.
- Reusable file and memory-only Java compilation APIs.
- Interpreter support for all Java byte codes including invokedynamic.
- Fully asynchronous, non-blocking execution using Rust async/await for:
- java.lang.Thread
- java.io & java.nio
- java.net
- A low-pause, concurrent, and parallel mark-and-sweep garbage collector.
- Parallel Just-In-Time (JIT) compilation for x86-64, aarch64, s390x, and riscv64 architectures.
- WebAssembly (WASM) compilation support for single-threaded edge and browser deployments.
Examples
use ristretto_vm::{VM, Configuration, ConfigurationBuilder};
use ristretto_classloader::ClassPath;
#[tokio::main]
async fn main() -> ristretto_vm::Result<()> {
// Create a VM configuration
let configuration = ConfigurationBuilder::new()
.class_path(ClassPath::from(&["/path/to/classes"]))
.build()?;
// Create the VM instance
let mut vm = VM::new(configuration).await?;
// Execute main method of a class
let _ = vm.invoke_main(&[] as &[&str]).await?;
Ok(())
}
Java sources can be compiled directly from memory:
use ristretto_vm::{Compiler, CompilerError};
#[tokio::main]
async fn main() -> Result<(), CompilerError> {
let compiler = Compiler::default().await?;
let classes = compiler
.compile_source("Hello", "public class Hello {}")
.await?;
assert!(classes.get("Hello").is_some());
Ok(())
}
Feature flags
ristretto_vm uses feature flags to address compile time and binary size uses.
The following features are available:
| Name | Description | Default? |
|---|---|---|
audio |
Enables javax.sound support |
Yes |
startup-trace |
Enables startup tracing | No |
tls-native-tls |
Enables Native TLS support | No |
tls-rustls-aws-lc-rs |
Enables Rustls with the AWS-LC crypto provider | No |
tls-rustls-ring |
Enables Rustls with the Ring crypto provider | Yes |
url |
Enables URL class path entries | No |
The TLS backend features are alternatives. To select a non-default backend without compiling Ring,
disable default features and enable tls-native-tls or tls-rustls-aws-lc-rs, together with any
other required features such as audio.
Dependencies
~20–68MB
~1M SLoC