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

Download history 38/week @ 2026-07-17 11/week @ 2026-07-24 10/week @ 2026-07-31 10/week @ 2026-08-07 11/week @ 2026-08-14 12/week @ 2026-08-21 4/week @ 2026-08-28 16/week @ 2026-09-04 8/week @ 2026-09-11 9/week @ 2026-09-18 184/week @ 2026-09-25 9/week @ 2026-10-02 12/week @ 2026-10-09 33/week @ 2026-10-16 50/week @ 2026-10-23 68/week @ 2026-10-30

164 downloads per month
Used in 8 crates (4 directly)

Apache-2.0 OR MIT

11MB
256K SLoC

Ristretto VM

Documentation Code Coverage Latest version License Semantic Versioning

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