jni-rs / jni-sys

Apache License 2.0
53 stars 19 forks source link

Updates from a more recent bindgen #1

Closed jrobsonchase closed 7 years ago

jrobsonchase commented 7 years ago
sfackler commented 7 years ago

Thanks!

It seems a bit unfortunate to have to unwrap function pointers everywhere - will the JVM actually null out any of those pointers? I guess it might things that aren't supported on that JVM version?

jrobsonchase commented 7 years ago

That I don't know - I'm assuming that later JVMs simply add functions to the end of the struct, so an attempt to access an invalid function for your JVM would technically be out-of-bounds since the struct that your JNIEnv pointer points to would be shorter.

So you'd either get uninitialized data that doesn't point anywhere (or to somewhere else entirely), or they might have anticipated adding more functionality later and allocated/zeroed a much larger structure than needed, in which case, it would actually be null pointers.

Unless benchmarks show that the unwrapping causes a nontrivial performance penalty, I figure better safe than sorry.

sfackler commented 7 years ago

Oh yeah, performance isn't the concern at all. I still hate that we have to option wrap function pointers in FFI, but here we are. :P

sfackler commented 7 years ago

Anything else you want to get in before I cut an 0.2 release?

jrobsonchase commented 7 years ago

Nope, I'm good 👍

sfackler commented 7 years ago

Done!