JNI get exception object class name
Hi,
I have written an application in which i am calling java method from C+
+ using JNI(Java Native Interface). I would like to handle exceptions
in C++ raised inside JAVA method. I am able to do that successfully. I
also want class name of the exception object in C++ and for that I
have written following code, but line no. 9 retruns null object(pease
see code below).
1 jobject jResponseMailbox = jenv->CallStaticObjectMethod(...);
2 if(jenv->ExceptionCheck() == JNI_TRUE )
3 {
4 jthrowable exceptionObj = jenv->ExceptionOccurred();
5 jclass exceptionClass = jenv->GetObjectClass( exceptionObj );
6
7 jmethodID msgMethodID;
8 const char* localstr = NULL;
9 msgMethodID = jenv->GetMethodID(exceptionClass, "getName",
"()Ljava/lang/String;");
10 if(msgMethodID == NULL) {
11 printf("\ngetName is returning NULL......\n");
12 } else {
13 jstring clsName = (jstring)jenv-
CallObjectMethod(exceptionClass, msgMethodID, NULL);
14 localstr = jenv->GetStringUTFChars(clsName, NULL);
15 printf("\n\nException class name: %s\n", localstr);
16 }
17 }
Can you please suggest me how to get class name?
Thank you,
Jaydeep