short 데이터형 값 주고 받기
$ vi PassAndReturnShort.cpp#include <jni.h>
jshort max
(
JNIEnv *env,
jobject thiz,
jshort a,
jshort b
)
{
if( a > b )
return a;
return b;
}
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 {
const_cast<char *>("max"),
const_cast<char *>("(SS)S"),
reinterpret_cast<void *>(max)
};
jclass cls = env->FindClass("Client");
env->RegisterNatives(cls, &nm, 1);
return JNI_VERSION_1_6;
}Last updated