I have a Carbonized C++ app that needs to call a function in a small
jar file. I'm looking at both simpleJavaLauncher, and
JavaSplashScreen. I see that both have a "startupJava()" function that
initializes the JavaVM in a separate thread, loads and calls the "main"
function, and then quits the JavaVM. I would like to be able to load
the JavaVM once, load the "main" function once, and then call it
multiple times asynchronously. Also, I would like to use Carbon Events
to communicate between the main thread, and the thread containing the
JavaVM.
I first changed "simpleJavaLauncher" to use "MPCreateTask" instead of
pthreads. This seems to work just fine.
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:
#0 0x93199bec in HIObjectIsOfClass
#1 0x931b07d8 in _HIMenuBarViewGetAvailableSpace
#2 0x931b0744 in SetMenuBarLimits
#3 0x931a4350 in ShowBar
#4 0x93250c20 in SetSystemUIMode
#5 0x9367debc in -[NSApplication finishLaunching]
#6 0x9deb21f4 in -[NSApplicationAWT finishLaunching]
#7 0x9367d98c in -[NSApplication run]
#8 0x9deb0f34 in +[AWTStarter startAWT:]
#9 0x928e8f00 in __NSFireMainThreadPerform
#10 0x9078df20 in __CFRunLoopPerformPerform
#11 0x9075da5c in __CFRunLoopDoSources0
#12 0x9075cf8c in __CFRunLoopRun
#13 0x9075ca0c in CFRunLoopRunSpecific
#14 0x931831e0 in RunCurrentEventLoopInMode
#15 0x93182874 in ReceiveNextEventCommon
#16 0x931c7ca4 in AcquireNextEventInMode
#17 0x931c7a94 in RunApplicationEventLoop
#18 0x00003b84 in main at simple.c:634
I notice that something appears to be trying to start up AWT, but is
failing for some reason. I haven't changed anything that the JavaVM
code does, yet the "simpleJavaLauncher" application didn't fail like
this before.
Is it even possible to keep the JavaVM loaded long enough to call a
Java function more than once? If so, what do I have to initialize and
when in order to get the Java code off the ground?
Any help would be greatly appreciated.
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