JNI's callback from C++ to Java in a new thread
843829Oct 16 2007 — edited Oct 18 2007I met a problem when I want to call back to Java in C++'s new thread on MAC OS X.
Firstly, I call a C++'s function through JNI in Java. In that function, I save the JavaVM pointer by using "JNIEnv->GetJavaVM()". Then I create a new thread in C++, and pass the JavaVM pointer as a argument. In the new thread, I call "AttachCurrentThread" to get a new JNIEnv, according to JNI Tutorial.Finally, I call ""JNIEnv->FindClass()" to get the class, which I want to call back in Java.
However, when I call "JNIEnv->GetStaticMethodID()", it is to say that there is a invalid memory access and the process quit.
There is no problem when I run my code on Windows&Linux.
So my question is that how can I call back to Java in C++'s new thread on MAC OS X.
Any comment will be appreciated. Thanks.