Robert Lougher wrote:
It would be an interesting question to ask if JNI code
should expect the JNIEnv* to be different for different threads. Opinions?

Stop the nonsense! :-)

The idea that there is anything other than a 1:1 pairing between
threads and JNIEnv * pointers is crazy^H^H^H^H^Hincorrect. Quoting:

  http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/design.html

The JNI interface pointer is only valid in the current thread. A native method, therefore, must not pass the interface pointer from one thread to another. A VM implementing the JNI may allocate and store thread-local data in the area pointed to by the JNI interface pointer.

Native methods receive the JNI interface pointer as an argument. The VM is guaranteed to pass the same interface pointer to a native method when it makes multiple calls to the native method from the same Java thread. However, a native method can be called from different Java threads, and therefore may receive different JNI interface pointers.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


_______________________________________________ Classpath mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to