convert ExceptionDescribe to string
I need to get 开发者_如何学运维the output of ExceptionDescribe() in JNI as string so I can write it afterwards in a file instead of writing it directly on command line. Is there any way or idea how to do that?
Thanks in Advance,
Sami
ExceptionOccurred is a first step, to get to the message and stack trace one can do:
jboolean isCopy = false;
jmethodID toString = env->GetMethodID(env->FindClass("java/lang/Object"), "toString", "()Ljava/lang/String;");
jstring s = (jstring)(*env)->CallObjectMethod(exc, toString);
const char* utf = (*env)->GetStringUTFChars(s, &isCopy);
You have apparently use the ExceptionOccured()
method.
jthrowable exc;
exc = (*env)->ExceptionOccurred(env);
精彩评论