Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I launch and keep the JavaVM around?



On Jan 04, 2006, at 06:09 PM, Scott Fraser wrote:

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

This email sent to email@hidden
References: 
 >Can I launch and keep the JavaVM around? (From: Scott Fraser <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.