JNI_CreateJavaVM: Buffer overrun if I throw an exception in case of failure

Posted by Dominik Fretz on Stack Overflow See other posts from Stack Overflow or by Dominik Fretz
Published on 2010-05-31T09:19:12Z Indexed on 2010/05/31 9:22 UTC
Read the original article Hit count: 355

Filed under:
|
|

Hi,

In a C++ project, I use the JNI invocation API to launch a JVM. I've done a little wrapper arount the JVM so I can use all the needed parts in a OO fashion. So far that works great.

Now, if the JVM does not start (JNI_CreateJavaVM returns a value < 0) I'd like to raise an exception within my C++ code.But if I throw an exception after JNI_CreateJavaVM, I get a buffer overrun. If I raise the exception without the JNI_CreateJavaVM call, it works as expected.

Does anyone have a clue on what the issue could be here? Or how to debug this?

Environment: Windows, Visual Studio 2008 JDK: jrockit27.6jdk16005, but happens with SUN stock one as well

Cheers Dominik

© Stack Overflow or respective owner

Related posts about c++

Related posts about exception