I already posted a question about this, but at the time I do not have an account. I got an answer, but I was still confused, and I can not continue this topic.
I am sending the question again with a link to the previous conversation.
Returning char array from java to string - JNI
Data stored in Java is serialized. I am making a java function call using the following code snippet.
The following code assumes that char of C is compatible with the Java byte, because char Java has 2 bytes, while char of C has 1 byte. Jbyte is also a signed char *
void store(char* key, char* value, int val_len)
{
jstring j_key = (*env)->NewStringUTF(env, key);
jbyteArray j_value = (*env)->NewByteArray(env, val_len);
(*env)->SetByteArrayRegion(env, j_value, 0, val_len, (jbyte *)value);
(*env)->CallStaticVoidMethod(j_class, store_method, key, value);
(*env)->ReleaseByteArrayElements(env, j_value, (jbyte *)value, JNI_ABORT);
(*env)->ReleaseStringUTFChars(env, j_key, key);
}
, . , . API C, Java. C- Java. , Java .
C Java, C . , . ( java), GetByteArrayElements. , , , , NewByteArray, Java-.