Writing JVM in Rust to play Minecraft.
Ambitious project to learn rust (trying my best).
As of today 28/04/2025, this project has been developed as a side project after work in three weeks => not the best code. :)
After a long pause where I searched for a job (found it), worked on my master thesis, and took care of my mental health (it is important!!!), I finally continued this project and implemented sockets! (10/07/2025)
This is my first "big" rust project !
NOTE: Only tested on openjdk-23.0.2
Milestones:
- System.out.Println (~2M instructions x.x)
- Sockets
- Multithreading
- Minecraft Server
- Minecraft
Since the goal of the project is to run minecraft, I will first implement opcodes/internals needed to run it, and in a second moment implement what's left.
NOTE: The JVM is really dependent on openjdk-23.0.2 implementation (especially related to MethodHandle)
TODO:
- create class loader logic
- separate class based on the class loader
- init threads
run initPhase1 and initPhase2 and initPhase3handle CallSite/MethodHandle/LambdaMetaFactoriessockets- memoization of some boxed values (bool, byte, short, etc.)
- ahead-of-time compilation of some classes (e.g.
DirectMethodHandle$Holder) -- falling back to dynamically generated bytecode (slow path) - continue testing
Some vm properties are obtained from env variables such as :
| vm property | env variable | description |
|---|---|---|
| java.home | JHOME | |
| user.home | JUHOME | |
| user.dir | JUDIR | |
| java.io.tmpdir | JTMPDIR | |
| java.library.path | JLIB | LD_LIBRARY_PATH |
Download the java modules:
curl -L -o openjdk.tar.gz https://download.java.net/java/GA/jdk23.0.2/6da2a6609d6e406f85c491fcb119101b/7/GPL/openjdk-23.0.2_linux-x64_bin.tar.gz
mkdir openjdk
tar -xzf openjdk.tar.gz -C openjdk --strip-components=1
./openjdk/bin/jimage extract --dir java_modules ./openjdk/lib/modulesRun it:
javac samples/print/Print.java
JMODS=/path/to/java_modules cargo run -- -u samples -c print.Print -m main -d "()V"where JMODS is the folder with the java modules just downloaded.
- JFR
- Multithreading (Virtual Thread/Carrier Threads)
- Virtual Object (every object is materialized)
- Multi OS support (Only linux supported)
- No hidden classes
- IPv6
In the future, unit tests MUST be written, but at the moment I do not have time for them. :)
During init, initPhase1 and initPhase2 and initPhase3 should always be called ?