kud1ing / rucaja

Calling the JVM from Rust via JNI
https://docs.rs/rucaja
Apache License 2.0
31 stars 7 forks source link

Type for holding Java objects #11

Closed kud1ing closed 7 years ago

kud1ing commented 7 years ago

Currently there are JvmClass, JvmObject and JvmStrings to bring some compile time type safety into Rust regarding different JVM classes. Unfortunately there is some code duplication.

Come up with an optimal way to hold Java objects in a Rust type that reflect the most specific Java class.

Aspects:

Options:

treyzania commented 7 years ago

You could probably write some macros to make this more ergonomic. I'm not sure how possible it would be but perhaps you could design a procedural macro that just takes Java code and generate structs/impls to mirror it.

kud1ing commented 7 years ago

Indeed rawrasaur/rust-jdbc uses some macros: https://github.com/rawrasaur/rust-jdbc/blob/5ad63b8f06ce1ded4e5c731cbae26c69d6c4b457/src/lib.rs

kud1ing commented 7 years ago

Yeah, that worked quite well actually: https://github.com/kud1ing/rucaja/commit/4d776df9aae45e257ed80d61132251d406dd905d