Note that there are some explanatory texts on larger screens.

plurals
  1. POInvoking Java from C++: how to catch/detect a fatal JVM error?
    text
    copied!<p>I'm developing a C++ program (Win32, MS Visual Studio 2008) which creates a Java VM via JNI as outlined <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html#wp16334" rel="nofollow">here</a>. It has been working fine for a long time, with both Java 6 and Java 7.</p> <p>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 <code>JNI_CreateJavaVM</code> call; but calling <code>JNI_CreateJavaVM</code> causes the program to instantly terminate. No return values, no error messages, nothing.</p> <p>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.</p> <p>Is there a way to detect such type of errors in JRE, or more generally, in a third-party library? I tried using C++ <code>try/catch</code> constructs, I tried using the <a href="http://msdn.microsoft.com/en-us/library/xdkz3x12%28v=vs.71%29.aspx" rel="nofollow">signal</a> function - nothing helps; the program disappears without calling any catch or signal handlers.</p> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload