bool JniHelper::getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((nullptr == className) || (nullptr == methodName) || (nullptr == paramCode)) { return false; } JNIEnv *env = JniHelper::getEnv(); if (!env) { return false; } jclass classID = _getClassID(className); if (! classID) { LOGE("Failed to find class %s", className); env->ExceptionClear(); return false; } jmethodID methodID = env->GetMethodID(classID, methodName, paramCode); if (! methodID) { LOGE("Failed to find method id of %s", methodName); env->ExceptionClear(); return false; } methodinfo.classID = classID; methodinfo.env = env; methodinfo.methodID = methodID; return true; }
bool PluginJniHelper::getMethodInfo(PluginJniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((NULL == className) || (NULL == methodName) || (NULL == paramCode)) { return false; } JNIEnv *pEnv = PluginJniHelper::getEnv(); if (!pEnv) { return false; } jclass classID = _getClassID(className, pEnv); if (! classID) { LOGD("Failed to find class %s", className); return false; } jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode); if (! methodID) { if(pEnv->ExceptionCheck()) { pEnv->ExceptionClear(); } LOGD("Failed to find static method id of %s in class %s with params %s", methodName, className, paramCode); return false; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; return true; }
bool JniHelper::getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((NULL == className) || (NULL == methodName) || (NULL == paramCode)) { return false; } JNIEnv *pEnv = JniHelper::getEnv(); if (!pEnv) { return false; } jclass classID = _getClassID(className); if (! classID) { LOGD("Failed to find class %s", className); return false; } jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode); if (! methodID) { LOGD("Failed to find method id of %s", methodName); return false; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; return true; }
bool JniHelper::getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { try { if ((nullptr == className) || (nullptr == methodName) || (nullptr == paramCode)) { return false; } JNIEnv *env = JniHelper::getEnv(); if (!env) { LOGE("Failed to get JNIEnv"); return false; } jclass classID = _getClassID(className); if(env->ExceptionCheck()) { LOGE("exst Failed to find class %s", className); env->ExceptionDescribe(); env->ExceptionClear(); return false; } if (! classID) { LOGE("Failed to find class %s", className); env->ExceptionDescribe(); env->ExceptionClear(); return false; } jmethodID methodID = env->GetStaticMethodID(classID, methodName, paramCode); if(env->ExceptionCheck()) { LOGE("exst Failed to find static method id of %s", methodName); env->ExceptionDescribe(); env->ExceptionClear(); return false; } if (! methodID) { LOGE("Failed to find static method id of %s", methodName); env->ExceptionDescribe(); env->ExceptionClear(); return false; } methodinfo.classID = classID; methodinfo.env = env; methodinfo.methodID = methodID; } catch (...) { return false; } return true; }
bool JniHelper::getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((nullptr == className) || (nullptr == methodName) || (nullptr == paramCode)) { return false; } JNIEnv *env = JniHelper::getEnv(); if (!env) { BEATS_ASSERT("Failed to get JNIEnv"); return false; } jclass classID = _getClassID(className); if (! classID) { BEATS_ASSERT("Failed to find class %s", className); env->ExceptionClear(); return false; } BEATS_ASSERT(methodName != NULL, _T("methodName can't be null!")); BEATS_ASSERT(paramCode != NULL, _T("paramCode can't be null!")); jmethodID methodID = env->GetStaticMethodID(classID, methodName, paramCode); if (! methodID) { BEATS_ASSERT("Failed to find static method id of %s", methodName); env->ExceptionClear(); return false; } methodinfo.classID = classID; methodinfo.env = env; methodinfo.methodID = methodID; return true; }