JNIEnv详解

JNI.h:(详解)

struct JNIEnv_;
#ifdef __cplusplus
typedef JNIEnv_ JNIEnv;
#else
typedef const struct JNINativeInterface_ *JNIEnv;
#endif

struct JNINativeInterface_ {
const char* (JNICALL *GetStringUTFChars)
}

struct JNIEnv_ {
    const struct JNINativeInterface_ *functions;
    #ifdef __cplusplus
    const char* GetStringUTFChars(jstring str, jboolean *isCopy) {
            return functions->GetStringUTFChars(this, str, isCopy);
        }
    }
JNIEXPORT jstring JNICALL Java_com_popoaichuiniu_jacy_examplelearning_Command_getStringFromC
  (JNIEnv * env, jclass cls, jstring j_str)
//C:
(*env)->GetStringUTFChars(JNIEnv * env, jclass cls, jstring j_str)
//C++:
env->GetStringUTFChars(jstring str, jboolean *isCopy)

notice:C++不需要参数JNIEnv *

你可能感兴趣的:(android安全)