classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GTK peer switching JNIEnv *?


From: Etienne Gagnon
Subject: Re: GTK peer switching JNIEnv *?
Date: Fri, 14 Jan 2005 09:18:31 -0500
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Robert Lougher wrote:
Opinions?

How about "specification" instead?  :-)

http://java.sun.com/docs/books/jni/html/design.html#10110

 11.5.1 Organization of the JNIEnv Interface Pointer
 ...
 Because the JNIEnv interface pointer is thread-local, native code must
 not use the JNIEnv interface pointer belonging to one thread in another
 thread. Native code may use the JNIEnv pointer as a thread ID that
 remains unique for the lifetime of the thread.


Actually, it's even documented as a common pitfall:

http://java.sun.com/docs/books/jni/html/pitfalls.html#11233

 10.14 Using the JNIEnv across Threads

 The JNIEnv pointer, passed as the first argument to every native
 method, can only be used in the thread with which it is associated. It
 is wrong to cache the JNIEnv interface pointer obtained from one
 thread, and use that pointer in another thread. Section 8.1.4 explains
 how you can obtain the JNIEnv interface pointer for the current thread.


Etienne

--
Etienne M. Gagnon, Ph.D.            http://www.info2.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]