user987379
user987379

Reputation: 23

Recovery from JVM crash

I m working on a swing based java application which uses 3rd party library functions by loading DLL .

Some functionality in the DLL calls exit(1) which is closing the entire java application. Is there any solution which can keep my JVM alive if it encounters with exit(1). I don't have access to the C source code.

Upvotes: 0

Views: 435

Answers (3)

Stephen C
Stephen C

Reputation: 719336

A 3rd party library that calls System.exit() is broken. A 3rd party library that calls the C exit() library method is even more broken. Lodge a bug report with the vendor and consider switching to a better alternative.

You could possibly stop System.exit() from working by using a security manager that blocks the call. But I'm not sure that a call coming from a DLL would be controlled by the security manager.

Upvotes: 6

NPE
NPE

Reputation: 500773

If you can't change the way the DLL behaves, and can't use it in a manner where it won't call exit(), your best bet might be invoke its functionality in the context of another process. It will then be this other process that goes down, and your main process will not be affected.

Whether this is a practical workaround in your case, I don't know.

Upvotes: 3

user207421
user207421

Reputation: 311018

exit() is exit(), nothing you can do about that. Complain to the vendor of the DLL.

Upvotes: 0

Related Questions