开发者

convert ExceptionDescribe to string

开发者 https://www.devze.com 2023-03-05 23:54 出处:网络
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

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消