This content has been marked as final. Show 3 replies
I don't know what you mean by 'glued code', but you can't save jobjects across JNI method invocations unless you convert them to GlobalReferences.
It sounds like you need to allocate a C++ callback object per Java object and keep your state in there. You can associate it with the Java object via a long to keep its address in. Make sure to delete it when finished with it.
Thanks for you answer! By "glue code" I mean the C code that's used to "glue" the Java code to the 3 ^rd^ party lib. I've seen this term here: en.wikipedia.org/wiki/Glue_code.
I've already converted my objects to "GlobalReferences". My example is running perfectly when I have just one instance of the Java wrapper object.
So, if I understood it correctly you're suggesting that I cache the values in the Java object itself? So, what I have to do is to just have a "long" in my Java object with the memory addresses. And is the "long" always valid, whether I'm running a 32 bits or 64 bits version?
Just one more thing. When you say "Make sure to delete it when finished with it", what do you mean?
Once again, many thanks!