int 데이터형 값 주고 받기
$ vi PassAndReturnInt.cpp#include <jni.h>
jint PassAndReturnInt
(
JNIEnv *env,
jobject thiz,
jint data
)
{
return data * data;
}
JNIEXPORT jint JNICALL JNI_OnLoad
(
JavaVM *vm,
void *reserved
)
{
JNIEnv *env;
if(vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6)) {
return -1;
}
JNINativeMethod nm[1];
nm[0].name = const_cast<char *>("PassAndReturnInt");
nm[0].signature = const_cast<char *>("(I)I");
nm[0].fnPtr = reinterpret_cast<void *>(PassAndReturnInt);
jclass cls = env->FindClass("Client");
env->RegisterNatives(cls, nm, 1);
return JNI_VERSION_1_6;
}Last updated