{"id":13578741,"url":"https://github.com/andreabergia/rjvm","last_synced_at":"2025-10-04T11:48:13.865Z","repository":{"id":144835301,"uuid":"600413297","full_name":"andreabergia/rjvm","owner":"andreabergia","description":"A tiny JVM written in Rust. Learning project","archived":false,"fork":false,"pushed_at":"2024-01-24T08:02:43.000Z","size":19992,"stargazers_count":1521,"open_issues_count":4,"forks_count":84,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-23T00:07:24.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreabergia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-11T12:19:50.000Z","updated_at":"2025-05-20T23:25:06.000Z","dependencies_parsed_at":"2024-08-01T15:40:03.810Z","dependency_job_id":null,"html_url":"https://github.com/andreabergia/rjvm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreabergia/rjvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabergia%2Frjvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabergia%2Frjvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabergia%2Frjvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabergia%2Frjvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreabergia","download_url":"https://codeload.github.com/andreabergia/rjvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabergia%2Frjvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278308628,"owners_count":25965654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:33.365Z","updated_at":"2025-10-04T11:48:13.836Z","avatar_url":"https://github.com/andreabergia.png","language":"Rust","funding_links":[],"categories":["Rust","Java 程序设计","JVM实现","others"],"sub_categories":["网络服务_其他"],"readme":"# RJVM\n\nThis project is an attempt to write a minimal JVM 7 using Rust.\n\nImportant note: **this is a hobby project, built for fun and for learning purposes**. In particular, it is my first real\nprogram in Rust and I've used to learn the language - thus, I'm sure some parts of the code are not very \"idiomatic\"\nRust since I'm just learning the language.\n\nThe code quality is definitely not production ready - there are not enough tests, there isn't enough documentation and\nsome of the initial decision should be revisited. (I.e.: this is not representative of the code I write for work 😊.)\n\nThe code is licensed under the [Apache v2 license](./LICENSE).\n\nThe architecture is discussed in a series of posts on my blog, [https://andreabergia.com](https://andreabergia.com/series/writing-a-jvm-in-rust/).\n\n## What has been implemented and what hasn't\n\nThe current code can execute [various simple programs](./vm/tests/resources/rjvm), but it has a lot of limitations.\n\nHere is a list of the implemented features:\n\n- parsing .class files\n- resolving classes from a jar file, or from a folder\n- execution of real code:\n    - primitive types, arrays, strings\n    - control flow statements\n    - classes, subclasses, interfaces\n    - methods (virtual, static, natives)\n    - exception throwing and catching\n    - stack traces\n    - garbage collection\n\nHowever, there are a lot of important things not implemented (and not planned to):\n\n- threading\n- multi dimensional arrays\n- reflection\n- annotations\n- [class file verification](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10)\n- I/O\n- just in time code execution (JIT)\n- proper class loaders\n\nThe JVM uses the _real classes_ from [OpenJDK 7](https://jdk.java.net/java-se-ri/7) - meaning the classes such as\n`java.lang.Object`, `java.lang.String` or `java.lang.Exception` are real production classes, without any modifications.\nThe JVM is \"good enough\" to parse and execute their code, something which makes me very happy indeed. 😊\n\nThe VM is limited to 64 bits platforms, as there are quite a few places where I assume that the size of a pointer\nis exactly 8 bytes.\n\n## Implementations that should be modified\n\nOne poor implementation detail is that for things like stack overflow, accessing an array out of bounds, divisions by\nzero, etc. I should be throwing real java exceptions, rather than internal errors that will abort executions.\nIn general, the error handling is not great - there are no details when you get an internal error, something that made\ndebugging more painful than it should have been.\n\nThere's also quite a few things whose implementation is quite poor, or not really coherent with the JVM specs,\nbut it is \"good enough\" to execute some simple code; for example I do not have a class for arrays. If you're curious,\nlook for the TODO in the code.\n\nI'm also quite sure there's a million bugs in the code. 😅\n\n## Code structure\n\nThe code is currently structured in three crates:\n\n- `reader`, which is able to read a `.class` file and contains various data structures for modelling their content;\n- `vm`, which contains the virtual machine that can execute the code as a library;\n- `vm_cli`, which contains a very simple command-line launcher to run the vm, in the spirit of the `java` executable.\n\nThere are some unit test and some integration tests - definitely not enough, but since this is not production code but\njust a learning exercise, I'm not that worried about it. Still, IntelliJ tells me I have a bit above 80% of coverage,\nwhich is not bad. The error paths aren't really tested, though.\n\nI use [just](https://github.com/casey/just) as a command runner, but most tasks are just cargo commands.\n\n# Project status and further works\n\nI consider the project complete. It was super instructive, but I do not plan to keep working on it.\n\nThe only thing I'm considering is to extract the `reader` crate in a separate repository, and publish it on\n[crates.io](https://crates.io/), since it could actually be useful to someone else.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreabergia%2Frjvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreabergia%2Frjvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreabergia%2Frjvm/lists"}