10

I have to call a Java method from JNI. This Java method returns int array (int[] simpleMethod()). How to call this from JNI to get the array as a return value? I know how to do this when method returns void/String/int/etc but couldn't find anything with arrays. I have some ideas how to work around this but maybe there is simple answer.

1 Answer 1

25

Use CallObjectMethod. For example:

jmethodID myMethod = (*env)->GetMethodID(myClass, "myMethod", "()[I");
jintArray retval = (jintArray) (*env)->CallObjectMethod(myObject, myMethod);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.