I am still looking at some code, not mine - X-platform language
interface kind of a deal (ooRexx to java), that attempts to launch a
JVM from JNI. This code may do AWT or Swing so I am trying to do it
off the main thread as recommended in the simpleJavaLauncher sample.
As I noted before the existing sample seems to either exit the code
entirely or hang. So I have been trying to familiarize myself with
CFRunLoop and related to come up with a better way of handling this.
Eventually I seemed able to serialize the processing somewhat
BsfLoadJava(): AFTER create a JVM, res=, JNI=
globObj=0x0, globVm=0xac875ee8, globORef=0x0, globJavaVM=0x0
BsfLoadJava(): about to leave...
So the JVM is started along the lines of the sample code and signal
posting the completion callback stops the runloop and the code returns.
Unfortunately a little farther on it gets a...
Program received signal EXC_BAD_ACCESS, Could not access memory.
Looking into the flow it appeared a callback from the java into the
JNI code was not being done. Looking at the java I noticed there was
some logger functionality so I added the appropriate logging jar to
Surprisingly the JVM callback into the JNI code then started working,
so apparently missing the logging jar was causing something to fail
However, now again the serialized processing has disappeared, the
'return' message above is never reached.
BsfLoadJava(): about to leave...
current 3146400 not waiting
callback stopping runloop 3146400
and nothing after that. So with that working it almost seems a
deadlock or something has been introduced? (Also why does the runLoop
seem to not be waiting? Although the completion callback is still hit
when it's source is added and the runloop stop issued).
gdb partial trace
#0 0x9000b348 in mach_msg_trap ()
#1 0x9000b29c in mach_msg ()
#2 0x907ddad8 in __CFRunLoopRun ()
#3 0x907dd3dc in CFRunLoopRunSpecific ()
#4 0x93299b20 in RunCurrentEventLoopInMode ()
#5 0x932991b4 in ReceiveNextEventCommon ()
#6 0x93299020 in BlockUntilNextEventMatchingListInMode ()
#7 0x937c4bc4 in _DPSNextEvent ()
#8 0x937c4888 in -[NSApplication
#9 0x937c0dcc in -[NSApplication run] ()
#10 0x9fe4c808 in +[AWTStarter startAWT:] ()
#11 0x92bef92c in __NSFireMainThreadPerform ()
#12 0x9080ea3c in __CFRunLoopPerformPerform ()
#13 0x907de42c in __CFRunLoopDoSources0 ()
#14 0x907dd95c in __CFRunLoopRun ()
#15 0x907dd3dc in CFRunLoopRunSpecific ()
#16 0x907ec83c in CFRunLoopRun ()
#17 0x000e58cc in BsfLoadJava ()
+[AWTSTarter startAWT:] comes up about 150 times on Google but
nothing real revealing to me.
This past list thread seems somewhat similar...
Can I launch and keep the JavaVM around?
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.
Seems to describe the rock and hard place you are between with hangs
So, roughly what I would like to do is start a JVM I can do AWT on,
then keep it around for reuse.
How should I approach doing this? Has anyone been successful with
code I can see that does similar? Are there any recommendations
beyond the sample code for this situation?
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden