JNI Failed to exclude type <unknown> ... how does this happen?

I have Java code that calls C ++ code, and C ++ code wraps around and calls Java, all through JNI. We received notorius "hs_err_pidXXXXX.log", which, oddly enough, happened when we called JNIEnv_::GetMethodID(myJniEnv->GetObjectClass(anException), "printStackTrace", "()V")in the current pending exception! So we added:

if ((javaException = getJniEnv()->ExceptionOccurred()) != NULL)
{
   jniEnv->ExceptionDescribe();
   .... <other exception handling code> ...
}

... after each time, we call JNI to try to figure out what the exception is. The result of ExceptionDescribe () was:

Uncaught exception of type <unknown>

How does this happen? The value anExceptionabove was JNI's direct call on anException = myJniEnv->ExceptionOccurred(), which should give a throw, right? I think I will be able to print a stack trace on the JNI that runs without breaking. Has anyone ever encountered anything like this before?

+5
1

, , - Java, . Java ( JVM C/++):

  -verbose:jni
  -verbose:gc
  -Xcheck:jni

, -Xcheck: jni (. ). , , , , . , java , (, gdb ++) java, , , , , , .

JNI Warrior ;)

+7

All Articles