How to properly cache Bridj JNI objects in Java/Scala

28 views
Skip to first unread message

Daniel Korzekwa

unread,
Aug 22, 2017, 10:57:15 AM8/22/17
to NativeLibs4Java

I'm looking for some guidelines on caching and reusing Bridj JNI objects between multiple JNI calls. I found that caching JNI objects vastly speeds up calling C functions over JNI but it also causes some numerical stability issues. Basically, sometimes the same C function with the same arguments produces different results.


I found this page discussing how to cache JNI objects. http://www.latkin.org/blog/2016/02/01/jni-object-lifetimes-quick-reference/


Does anyone do it in BridJ, any hints on how to cache primitives, structs, pointers, etc.?


Link to the same question on stackoverflow: https://stackoverflow.com/questions/45770502/how-to-properly-cache-bridj-jni-objects-in-java-scala


Daniel Korzekwa

unread,
Aug 23, 2017, 12:00:12 PM8/23/17
to NativeLibs4Java
I fixed my problems with caching Bridj JNI objects myself. I put some notes here: https://stackoverflow.com/questions/45770502/how-to-properly-cache-bridj-jni-objects-in-java-scala
Reply all
Reply to author
Forward
0 new messages