Low Level Java Virtual Machine. Contribute to davidar/lljvm development by creating an account on GitHub.
I thought this might interest you Rust folk. This is kinda like an LLVM bitcode to JVM bytecode translator. So run rustc with --emit=llvm-ir (I think that's the flag) and then pass the bitcode image to this program, then get JVM bytecode which you can make a JVM bytecode archive (JAR) from it. Could be an interesting? The author says it can JVM code from Clang output, so why not Rustc?
Keep in mind that these are two different beasts, JVM is designed for a safe virtual machine and LLVM is chiefly used to be translated into machine code. However, stupider and more wonderful things have been done with LLVM and JVM, for example, there's an LLVM to 6502 translator, so you could be making NES games with Rust.
I will test this in a few days, busy implementing my own JVM (hope I can do it) and I don't have the Rust toolchain installed on my system. But hey maybe someone can make a Cargo plugin from it (is it possible?)
I think I had a discussion with some people about this in the fediverse and they were practically in denial that it existed 😅 Some serious java hate.
It does make me wonder how Slint allows creation of Android apps... this transpiler is quite old, so it's doubtful slint is basing their dev on this. But it would be cool to write Android apps in pure Rust and have the toolchain spit out java bytecode with this that actually runs on android...
We can already write Android apps in pure Rust though. Android apps are allowed to run native machine code -- that's how the Android versions of Genshin Impact, CoD, Fortnite et. al. work -- and winit and wgpu support Android NativeActivity as a backend.
They are probably using Android NDK and generating glue code that calls the compiled library with it. It wouldn't surprise me if the actual solution is creating an activity with an OpenGL context into which apps can draw.
Regardless, I don't see the harm of transpiling parts of the app into JVM to access the full breadth of features. Take a look at what's missing on winit. There's probably more, but I'm not an android dev.