I have been doing what can only be described as "Peak Bullshit" for the past few days. The best way to describe it is "Combing Rust and Java in ways they were meant for, in the wrongest way possible"
I believe I have talked about Java's Project Panama before, but as a quick summery: it allows Java to call and interface with native libraries in a much nicer way than past methods (JNI, Java Native Interface, for example). Combing this with tooling like Jextract, which can read C headers and turn them into basic Classes full of basic helper methods, makes Panama extremely nice to work with as a developer. But with this stated, Panama does not require C, instead it needs programming languages that are compatible with the C ABI; which Rust is! As well, to accelerate workflows, there is a Rust "crate" (package) for auto-magically building C or C++ headers from FFI (Foreign Function Interface) compatible Rust structs/functions (called cbindgen); which works out of the box with Jextract.
Some examples of generated code. Image 1 is Jextract, image 2 is cbindgen
All of this comes together to this, Carbonated Cubes. Which is a Minecraft Mod idea I have had for a while - hyper optimized Multiblock structures that sidestep the standard MC world. Currently it is not much, but it shows a functioning prototype of Java <--> Rust communications! It is a bit of mess currently, but there is a State struct in Rust that will hold the state of a World, found here. Then, there is a FFI compatible wrapper around State called FFIState, this outlines the basic methods of communication to the State from outside of Rust.
Finally, the rising Rust meets the falling Java here (which references classes that only exists when the project's build script is ran). And the StateWrapper is a very simple wrapper around the FFIState, which translates the more esoteric Panama calls into basic Java Methods for easy use! But the abstract is a very comfortable place with no sharp edges - so this is why there are ad-hoc tests located here to test the Rust <--> Java communications.
TLDR:
A pretty cursed system that takes a basic Rust struct, and after some abstractions, converts it into a basic Java Object that doesn't need special treatment too be used.









