How to I get a global reference to a jlong?
843829Mar 30 2004 — edited Mar 31 2004Apologies if this is a rather basic question but I'm relatively new to JNI and my C is almost non-existant.
I am trying to track down the source of a JVM crash resulting from the execution of methods on my C++ JNI library. Having read a bit about global references I was checking that indeed all of the objects which should not be garbage collected are indeed not garbage collected.
My C++ code calls an external library. The objects (from Java) used to initialise this library are a byte array and a jlong.
The byte array is obtained using jenv->GetByteArrayElements and so, as I understand it, will not be garbage collected until I Release it. So, I guess the problem is not there.
But what about the jlong? Will that be garbage collected? I have tried "long myLong = myJLong;" (hoping that this will copy the value and so garbage collection is irrelevant) but this does not appear to help.
Note, I cannot set a new global ref on a jlong because a jlong is not a jobject.
Any help would be much appreciated, thanks.