Closed kud1ing closed 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.
Indeed rawrasaur/rust-jdbc
uses some macros: https://github.com/rawrasaur/rust-jdbc/blob/5ad63b8f06ce1ded4e5c731cbae26c69d6c4b457/src/lib.rs
Yeah, that worked quite well actually: https://github.com/kud1ing/rucaja/commit/4d776df9aae45e257ed80d61132251d406dd905d
Currently there are
JvmClass
,JvmObject
andJvmStrings
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:
jobject
is just a type alias to*mut _jobject
jclass
,jstring
etc. are just type aliases tojobject
IsInstanceOf()
compares ajobject
with ajclass
.Options: