rusty_jvm/lib.rs
1//! # Rusty JVM
2//!
3//! A Java Virtual Machine (JVM) interpreter written in Rust from scratch — with 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//! It currently supports a broad set of language features of Java 25, with garbage collection and multithreading planned for future releases.
7//!
8//! ## Features
9//! See the [README.md](https://github.com/hextriclosan/rusty-jvm/blob/rusty_jvm-v0.5.0/README.md#implemented-key-features) for the full list of implemented features.
10//!
11//! ## Usage
12//!
13//! ### 1. Create a simple Java program
14//! ```java
15//! public class Hello {
16//! public static void main(String[] args) {
17//! System.out.println("Hello, world!");
18//! }
19//! }
20//! ```
21//!
22//! ### 2. Compile the program
23//! ```sh
24//! javac Hello.java
25//! ```
26//!
27//! ### 3. Run it with Rusty JVM
28//! ```sh
29//! rusty-jvm Hello
30//! ```
31mod vm;
32use derive_new::new;
33use getset::Getters;
34use indexmap::IndexMap;
35pub use vm::run;
36
37#[derive(PartialEq, Debug, new, Getters, Default)]
38#[get = "pub"]
39/// Represents the command-line arguments for the Java program.
40pub struct Arguments {
41 /// The entry point for the Java program (e.g. `com.example.Main`).
42 entry_point: String,
43 /// The arguments passed to the Java program.
44 program_args: Vec<String>,
45 /// The standard Java options (e.g., `-version`, `-help`).
46 java_standard_options: Vec<String>,
47 /// The options passed to the Java launcher (e.g., `--dry-run`).
48 java_launcher_options: Vec<String>,
49 /// System properties set for the Java program (e.g., `-Dproperty=value`).
50 system_properties: IndexMap<String, String>,
51 /// JVM options (e.g., `-Xmx1024m`).
52 jvm_options: Vec<String>,
53 /// Advanced JVM options (e.g., `-XX:+UseG1GC`).
54 advanced_jvm_options: Vec<String>,
55}
56
57impl Arguments {
58 /// Creates a new `Arguments` instance with the specified entry point.
59 /// # Arguments
60 /// * `entry_point` - The entry point for the Java program.
61 /// # Returns
62 /// A new `Arguments` instance with the specified entry point and default values for other fields.
63 pub fn new_with_entry_point(entry_point: String) -> Self {
64 Self {
65 entry_point,
66 ..Default::default()
67 }
68 }
69}