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.

Advertisements

About Lance Finney

Father of two boys, Java developer, Ethical Humanist, and world traveler (when I can sneak it in). Contributor to Grounded Parents.
This entry was posted in Programming. Bookmark the permalink.

One Response to Silent Thread Death with JNI

  1. Lance Finney says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s