Callback invocation from native Code
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, November 25, 2005 08:17 AM

I have a Java application and want to call a Java method from a non JNI C++ method. The native Code creates on loading a new thread which should invoke preiodicaly a Java method. I tried it in this way: - I stored the pointer to the JVM in JNI_Onload - When the C++ method wants to call the Java method it retrieves the JNIEnv from the JVM and get all the necessary infos (like object and method id etc) My Problem is that I get a access violation exception when I try to access any of the JNIEnv methods (including the methods to get the monitor) and the system kills the JVM. The code is working perfectly when it is in a JNI native method. I now there are work arounds like just    More>>

I have a Java application and want to call a Java method from a non JNI C++ method. The native Code creates on loading a new thread which should invoke preiodicaly a Java method. I tried it in this way:

- I stored the pointer to the JVM in JNI_Onload

- When the C++ method wants to call the Java method it retrieves the JNIEnv from the JVM and get all the necessary infos (like object and method id etc)




My Problem is that I get a access violation exception when I try to access any of the JNIEnv methods (including the methods to get the monitor) and the system kills the JVM.
The code is working perfectly when it is in a JNI native method.



I now there are work arounds like just pulling the datas and so on. What interessts me is: Is it really not working (then why not?) or am I just to stupid to understand what went wrong?

   <<Less
About | Sitemap | Contact