Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNI calls deadlock inside JVM in Win2K Pro

843829Sep 4 2003 — edited Sep 10 2003
Hi, all,

I'm struggling with the following problem: We have a Win32 MFC application that has been in use for several years. We converted the app to a DLL and have been trying to get it to work by driving it from a browser-loaded applet.

We need to have the applet start up the dll and call into its message loop, and then we need to have a function inside the dll that calls back into the applet at specific moments in time.

We have managed to get most of this to work. However, eventually, after a smallish number of JNI calls, I invariably find the JVM is deadlocked. (Or at least I think it's deadlocked, all the thread stack traces look like JVM->JVM->...->JVM->KERNEL32->NTDLL.)

I'm pretty sure this is not a bug in my native code, which has been around for quite some time. I'm also quite sure this is not a bug in the applet code.

FYI, the applet callback method looks like this:
byte[] method(byte [])

The native method that calls this callback looks something like this:
NewByteArray
GetByteArrayElements
memcpy
ReleaseByteArrayElements
CallObjectMethod
GetByteArrayElements on the return array
memcpy
ReleaseByteArrayElements
DeleteLocalRef on the return array
DeleteLocalRef on the outbound array

The JNIEnv pointer and the local ref to the applet object are passed into the dll via the call into the message loop, which has not yet returned at this point, so presumably, they should be safe.

Is there anything anyone can tell me that might shed some light on this issue? I'd greatly appreciate it.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2003
Added on Sep 4 2003
25 comments
461 views