Europe and Russia Travelogue

25 Apr '05 - + 22 - 25 Silent Thread Death with JNI

In the application I'm writing for work, we use a third-party application that has a Java API wrapping native code (using JNI).  Under certain circumstances, one of the methods in the third-party application has a problem.  However, it doesn't throw an exception back to the calling code.  Instead, it displays an exception dialog and kills the thread.  This is really bad for my application, because it has resource management wrapped around the failing method, and the resource cleanup never happens, forcing the user to restart the application.

Is there any way to received notification that a thread has died?  Is there any way to be notified that a JNI method never finishes?  I've read a lot of JNI tutorials, and they all basically say not to do what this app does to avoid this situation.  However, none say what to do if you're stuck with it.

Only one comment:

It turns out I had completely misdiagnosed the problem. In fact, I was simply making a synchronous call across JNI, and a bug in the third-party application was causing control never to return.

An upgrade of the third-party application fixed it.

Lance Finney (link) - 02 May '05 - 21:10