I am facing issues with making a java call from C++ code using JNI. I am able to get the jobject, but the invoocation of any API on the jobject fails. On digging for nearly one day and comparing with other working Java API (jobjects which i call in my code), i found one difference.
the following piece of code
void printClassInfo(JNIEnv* env, jobject object, jclass klazz)
{
printf("printclass info 1\n");
printf("printclass info 2\n");
// First get the class object
jmethodID mid = env->GetMethodID(klazz, "getClass", "()Ljava/lang/Class;");
printf("printclass info 2.1\n");
jobject clsObj = env->CallObjectMethod(object, mid);
printf("printclass info 3\n");
if(clsObj == NULL){
printf("cls obj is null");
}
}
prints cls obj is null for the jobject for which I am seeing issues.
For other jobjects, the call does not return null.
The major difference is that it is a newly added class and I seemed to have missed something that can cause this issue. I have rechecked again and again but not getting any clear indicators.
Any help appreciated.