Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java pass by reference or value to C when using JNI ( more specifically Android NDK)

Does Java pass by reference or value to C when using JNI ( more specifically Android NDK)

like image 551
Faisal Abid Avatar asked Sep 10 '26 02:09

Faisal Abid


2 Answers

It depends on the type. Primitive types are passed by value and reference types by... reference. See http://java.sun.com/docs/books/jni/html/types.html

I can't speak to Android, but JNI passes values just like Java does, primitive types are passed by value and all objects (including arrays) are passed by reference. The wiki article on JNI is pretty good.

like image 20
Keith Randall Avatar answered Sep 11 '26 20:09

Keith Randall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!