Can I pass a string from Java to my C++ routine using JNI function calls and modify its value in the C++ routine?
So far, I have seen examples of returning jstring, which I do not want to do. The other option that I know about is to get the ID of the string variable within C++ and set its value.
At present, I am playing with a function like the following:
JNIEXPORT void JNICALL Java_myexample_ChangeString
(JNIEnv *, jobject obj, jstring strJava)
And I want to change strJava’s value. So, essentially what I am asking is if it Java can pass variables by reference and not just by value.
Thanks.
Java strings are immutable by design, you cannot change them, not even with JNI.