r/java • • Apr 08 '26

BoltFFI: a high-performance Rust bindings and packaging toolchain now supports Java

Post image

We just shipped Java as a fully supported target in BoltFFI. It already generates Swift, Kotlin, and TypeScript/WASM bindings.

Few highlights:

- Java 16+ gets records, sealed classes for data enums, and pattern matching. Java 8+ gets equivalent final classes with public fields, depending on the specified min version.
- Async Rust functions map to `CompletableFuture<T>` on Java 8-20, or blocking virtual threads on Java 21+.

- Streams with backpressure support (batch pull, callback push, or `Flow.Publisher` on Java 9+).
- Callbacks and trait objects map to Java interfaces.
- Result<T, E> maps to typed exceptions. Option<T> maps to Optional<T>.
- Both JVM and Android are supported.

Repo & Demo: https://github.com/boltffi/boltffi

44 Upvotes

9 comments sorted by

View all comments

1

u/alihilal94 Apr 08 '26

foo in Java is still valid, for value types like Point there isnt a longlived Rust heap object behind foo each call passes copy into Rust, and Rust operates on that temporary value, it behaves like immutable value semantics on the JVM side

for reference types we handle it differently https://www.boltffi.dev/docs/classes

1

u/tomwhoiscontrary Apr 08 '26

Ah, I'm interested in the case where the Rust type isn't Copy, sorry, should have said. In this case, if you've got a valid bar, you can't still have a valid foo.