SomethingSomething
SomethingSomething

Reputation: 12176

JNI: write into Java array given by parameter

I have the following JNI function:

JNIEXPORT void JNICALL Java_org_kuku_myProj_myClass
      (JNIEnv *env, jclass java_class, jbyteArray byte_array, jcharArray char_array) {


}

I want to write characters into the actual jcharArray passed to my function. How can I do it?

Upvotes: 0

Views: 196

Answers (1)

Oo.oO
Oo.oO

Reputation: 13375

Take a look here:

http://jnicookbook.owsiak.org/recipe-No-013/

where you can take a look at: (*env)->ReleaseBooleanArrayElements(env, array, body, mode) with different modes of change acceptance.

/* release body when you decide it is no longer needed
    Pass changes back to Java */
(*env)->ReleaseCharArrayElements(env, array, body, JNI_COMMIT);

Hope that helps.

Upvotes: 1

Related Questions