Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

douchuan/jvm.json
{
"createdAt": "2019-12-12T05:47:17Z",
"defaultBranch": "master",
"description": "JVM in Rust",
"fullName": "douchuan/jvm",
"homepage": "",
"language": "Rust",
"name": "jvm",
"pushedAt": "2026-04-23T01:11:06Z",
"stargazersCount": 531,
"topics": [
"jit",
"jvm",
"rust"
],
"updatedAt": "2026-07-04T03:17:32Z",
"url": "https://github.com/douchuan/jvm"
}

A JVM implementation written in Rust with an LLVM-based JIT compiler.

  • Class loading — directory, JAR, and JImage (JDK 9+ lib/modules) sources
  • Interpreter — all 202 JVM opcodes implemented (one file per opcode group)
  • LLVM JIT — ~110 opcodes translated to LLVM IR via inkwell (int/long/float/double arithmetic, bitwise, stack ops, type conversions, branching). Falls back to interpreter for uncompiled methods
  • Object model — slot-based heap (Oop::Ref(u32)), zero unsafe for object access. Safe Monitor via std::sync::{Mutex, Condvar}
  • JNI — ~30 native method implementations covering java.lang.*, java.io.*, sun.misc.*, sun.reflect.*
  • Threading — Java threads mapped to OS threads, with pool management
jvm/ # Binary crate — CLI entry point
crates/
classfile/ # JVM class file format type definitions (no dependencies)
class-parser/ # Bytes → ClassFile parser (Cursor + Read)
vm/ # Core VM: interpreter, JIT, oop model, native methods
class-verification/ # Class verification (skeleton)
tools/
javap/ # Class file disassembler (javap-style output)
jvm (binary) → vm → class-parser → classfile
↘ classfile
javap (tool) → class-parser → classfile
↘ classfile

All dependencies are centralized in the root Cargo.toml under [workspace.dependencies]. Sub-crates reference them with dep.workspace = true.

Terminal window
cargo build --workspace
cargo test --workspace
cargo run -p jvm -- --classpath /path/to/classes MyMainClass

See scripts/dev.sh for convenience commands.

Pure type definitions matching the JVM class file specification. No parsing logic.

Reads raw bytes and produces ClassFile. Uses std::io::Cursor + Read. Supports generics parsing via signature.rs.

ModuleDescription
oop/Object model — Oop enum, slot-based heap, instances, arrays, mirrors
runtime/interp/Bytecode interpreter (per-opcode files, no macros)
runtime/jit/LLVM JIT — bytecode → LLVM IR via stack-to-register conversion
runtime/invoke.rsMethod dispatch (JIT first, interpreter fallback)
runtime/class_path_manager.rsClasspath: directories, JARs, JImage
runtime/class_loader.rsClass loading + system dictionary
runtime/thread/Thread model, thread pool, Java monitor
native/JNI native method implementations (~30 classes)

CLI binary. Initializes VM (oop, runtime, native), resolves classpath, loads and runs the entry class.

Standalone javap-style disassembler. Reads class files and outputs human-readable representations including constant pool, fields, methods, bytecode, line numbers, and stack maps. Uses handlebars templates for rendering.

ComponentStateNotes
Class file parserDonenom → Cursor+Read rewrite complete
InterpreterDone202/202 opcodes
Method invocationDonev_table, static, special, interface
LLVM JITDone~110 opcodes, ~110 opcodes translated
Oop modelDoneSlot-based, zero unsafe
GCNot implementedFree-list allocation only, no collection
Class verificationSkeletonNo verification implemented
invokedynamicNot implemented
  • 5 class_path_manager tests fail due to missing test/ fixture directory
  • No garbage collection — objects are allocated but never reclaimed
  • invoke* bytecodes are not JIT-compiled; they fall back to the interpreter