Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNI's callback from C++ to Java in a new thread

843829Oct 16 2007 — edited Oct 18 2007
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2007
Added on Oct 16 2007
7 comments
5,073 views