Rust and Java Interop: A possible path for uProtocol uStreamer on Android VM
Pete LeVasseur
Rust @ Woven by Toyota ???? | Chair @ Rust Safety-Critical Consortium Coding Guidelines Subcommittee | Maintainer @ Eclipse uProtocol
Hey folks ??
One of the things I was asked most often while working on the Rust uStreamer and discussing integration with Java was:
"You can make Rust work with Java?!"
And yup, it's possible! The excellent Rust jni crate enables us to interact with Java in surprisingly useful ways, as if using JNI via C++, but with Rust's benefits of memory safety and thread safety.
I love learning and sharing new stuff, so I'll share some of what I learned, even if the Eclipse uProtocol design we came up with for a uStreamer with the Android VM turned out differently eventually.
Shout out to Mikhail Petrov for his excellent Java contributions to uProtocol like up-android-core, up-android-example, and up-transport-android-java I was able to build upon!
Read all the nifty details in my blog below ??
Owner / Software Engineer at EmbeddedWare Solutions specializing in Embedded
6 个月Using the jni interface not only means Rust is interoperable with Android's Java, but plain Java as well. It would be interesting if you could interop Rust through the binder/HAL layers using AIDLs too. It might be overkill for most applications, but it would be an interesting excercise.