How can we use the new primitive types in JNI. I have a function that returns a jobject . You can return jint , jchar , etc.
There is a NewString , why not NewInteger , NewCharacter , NewDouble , etc. At the moment, there is no autoboxing at the JNI level.
I can go with a call to NewObject , but for creating primitive types this would be too much overhead.
jobject NewInteger(JNIEnv* env, jint value) { jclass cls = FindClass(env, "java/lang/Integer"); jmethodID methodID = GetMethodID(env, cls, "<init>", "(I)V", false); return env->NewObject(cls, methodID, value); }
I have wrapper functions to get Class and MethodID.
Firat source share