I'm developing a C++ program (Win32, MS Visual Studio 2008) which creates a Java VM via JNI as outlined here. It has been working fine for a long time, with both Java 6 and Java 7.
Today I have installed a new version of JRE; something went wrong in the installer, and the JRE become corrupt. I noticed that my C++ program doesn't start and doesn't issue any warning messages. Debugging the program showed that it runs successfully until the JNI_CreateJavaVM
call; but calling JNI_CreateJavaVM
causes the program to instantly terminate. No return values, no error messages, nothing.
Yes, I know that I simply have to reinstall JRE. But nevertheless I'd like my C++ program to be prepared to such situation. If it's unable to create a Java VM, it should show a message "Please reinstall JRE". But I don't have a chance to show that message because the whole program is terminating.
Is there a way to detect such type of errors in JRE, or more generally, in a third-party library? I tried using C++ try/catch
constructs, I tried using the signal function - nothing helps; the program disappears without calling any catch or signal handlers.
Is there a way to detect such JRE crash? Or: is there a way to reliably detect a crash or termination inside a third-party library?