IMHO, you have two options: either pass JNIEnv* to each level, or pass your
C++ objects back to the top level, and use JNIEnv* on them there. The
second option would avoid you having to make all your classes "JNI-aware".
To avoid that with the first option, hide JNIEnv* in a struct or a class or
as a void*. Only the classes which use JNIEnv* would then have to be
"JNI-aware".

At 05:28 PM 3/28/00 +0000, Norman Shapiro wrote:
>The Java jni specifications require a JNIEnv* for almost all functions they
>provide.  Furthermore it seems that if multiple Java threads can access
the same
>function, each function call must use the JNIEnv* from the current thread.
>
>Given that function I am writing is maybe 20 deep in a call hierarchy of C++
>functions I have written, is there any way of accessing the correct JNIEnv*
>short of passing it all the way down as C++ function arguments?
>
>Putting it in a global or within a global class does not work in my case
because
>multiple Java threads can be using the same C++ function.
>
>I need a solution that works under Linux, though something that is
portable to
>Microsoft* would be ideal.



oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo
                         Send Sun a Message!
          Vote for JConfig in the JDJ Readers' Choice Awards.
            http://www.sys-con.com/java/readerschoice2000/
                 See the 'Best Class Library' category.
oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo0oo



----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to