rusty_jvm/
lib.rs

1//! # Rusty JVM
2//!
3//! A JVM interpreter written in Rust from scratch — no dependency on existing JVMs.
4//!
5//! `rusty-jvm` executes Java bytecode in interpreted mode and aims to support as much of the Java language as possible.
6//! Currently supports a range of Java language features up to Java 23 (excluding GC and lambdas for now).
7//!
8//! ## Features
9//! Refer to the [README.md](https://github.com/hextriclosan/rusty-jvm/blob/main/README.md#implemented-key-features)
10//!
11//! ## Usage Modes
12//!
13//! The binary supports three main modes, based on CLI arguments:
14//!
15//! - (default) Runs a Java class file with an entry point.
16//! - `--install` – Installs standard libraries (used by the VM).
17//! - `--purge` – Removes installed standard libraries.
18//!
19//! ## Example
20//! ### Installing core libraries
21//! ```bash
22//! rusty-jvm --install
23//! ```
24//! ### Creating a simple Java program
25//! ###### Windows
26//! ```bash
27//! echo public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } } > Hello.java
28//! ```
29//! ###### Unix-like systems
30//! ```bash
31//! echo 'public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } }' > Hello.java
32//! ```
33//! ### Compiling the Java program (current supported version is Java 23)
34//! ```bash
35//! javac Hello.java
36//! ```
37//! ### Running the compiled Java program with Rusty JVM
38//! ```bash
39//! rusty-jvm Hello
40//! ```
41mod vm;
42use derive_new::new;
43use getset::Getters;
44use indexmap::IndexMap;
45pub use vm::run;
46
47#[derive(PartialEq, Debug, new, Getters)]
48#[get = "pub"]
49/// Represents the parsed command-line arguments for the Java program.
50pub struct ParsedArguments {
51    /// The entry point for the Java program.  
52    /// This may be empty when running in install or purge mode.
53    entry_point: String,
54    /// The arguments passed to the Java program.
55    program_args: Vec<String>,
56    /// The standard Java options (e.g., `-version`, `-help`).
57    java_standard_options: Vec<String>,
58    /// The options passed to the Java launcher (e.g., `--install`, `--purge`).
59    java_launcher_options: Vec<String>,
60    /// System properties set for the Java program (e.g., `-Dproperty=value`).
61    system_properties: IndexMap<String, String>,
62    /// JVM options (e.g., `-Xmx1024m`).
63    jvm_options: Vec<String>,
64    /// Advanced JVM options (e.g., `-XX:+UseG1GC`).
65    advanced_jvm_options: Vec<String>,
66}