I then tried adding the ability to receive Carbon Events in the
secondary thread. This has proved difficult. I now have it to the
point where I call "RunApplicationEventLoop()" [or RAEL] on the main
thread, and then call "MPCreateTask" from the main-thread event
handler. On this secondary thread, I have called "ReceiveNextEvent",
and in response to a "start_my_java" event, I call the existing
"startupJava()" function. This successfully calls JNI_CreateJavaVM to
initiate Java. It then calls (still in "startupJava()" on the
secondary thread) "env->FindClass(xxx)". Before this call returns, I
get a "BAD_ACCESS" error on the main thread in the "RAEL" function
with the following stack trace:
As far as I can tell, in order to call Java from C or C++, it is
required that the JavaVM be instantiated on a secondary thread.
Further, it appears that calls from the secondary thread to Java JNI
functions will cause a transfer of control to the main thread. If the
main thread is blocked (for example, "MPWaitOnQueue") waiting for the
Java task to complete, the app hangs. If the main thread has any event
processing initiated (for example "RunApplicationEventLoop") the app
crashes.
Is there any way for a C or C++ application that is already processing
Carbon events to successfully make a call of any kind to a method in a
Java jar file?
Any help would be greatly appreciated.
Thanks.
Scott
-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden