java - Get fully-qualified class name from jclass (JNI) for use in FindClass -


let's assume hav instance of jclass:

auto objectclass = env->getobjectclass(obj); exception_return(env); 

on next line, want name of class , store can use findclass later on.

i've tried using getname() method returns java class name , can't use in findclass. here code getname() approach:

std::string getobjectclassname(jnienv* env, jobject javaobject) {     auto javaclass = env->getobjectclass(javaobject);     exception_return(env);      auto javaclassclass = env->findclass("java/lang/class");     exception_return(env);      auto javaclassnamemethod = env->getmethodid(javaclassclass, "getname", "()ljava/lang/string;");     exception_return(env);      auto javaclassnamejstring = (jstring)env->callobjectmethod(javaclass, javaclassnamemethod);     exception_return(env);      auto javaclassnamec = env->getstringutfchars(javaclassnamejstring, 0);     exception_return(env);     std::string javaclassname(javaclassnamec);      env->releasestringutfchars(javaclassnamejstring, javaclassnamec);     exception_return(env);      return javaclassname; } 

notice returned class name can't used in findclass() method. there simple way class name jclass object?


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -