Keep C pointer between JNI Call

Hello everyone,

I'm just starting with JNI.

I'd like to know how to keep C pointer between JNI Call.

So :

I've a C merthod wich create a handle to a specific hardware (a connection).

But i don't want to always recreate such handle, i would like to keep it.

So, what's the solution ? jniEnv pointer ?

Tks.

Regards,

Sebastien Degardin

[398 byte] By [sdegardina] at [2007-10-3 3:15:41]
# 1
You can create static variable within you dll or you can return your pointer to java in any appropriate form (as integer for example), pass back from java to C with every subsequent call and cast to C pointer.
Michael.Nazarov@sun.coma at 2007-7-14 21:07:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
The last poster is correct. However others have suggested, and I have used, a long rather than an integer (when holding the C pointer on the java side).
bschauwejavaa at 2007-7-14 21:07:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Thanks everyone.It works.However, i'll have to store GlobalRef in JNIEnv beceause i need to keep more than on pointer.Regards, Sebastien DegardinMessage was edited by: sdegardin
sdegardina at 2007-7-14 21:07:02 > top of Java-index,Java HotSpot Virtual Machine,Specifications...