Get<Primitive>ArrayElements may or may not copy data at its discretion. The isCopy parameter displays information about whether it was copied. If the data is not copied, you received a pointer to the data directly in the Dalvik heap. More details here .
You always need to call the appropriate Release<Primitive>ArrayElements , regardless of whether a copy was made. Copying the data back to the VM array is not the only cleanup that may need to be performed, although (according to the JNI documentation already linked), it is possible that the changes can be seen on the Java side before Release... was called Release... (if the data were not copied).
I do not believe that a virtual machine will allow you to make the transformations necessary in order to do what you think. As I can see, in any case, you will need to convert the byte array to float or float to the byte array in Java, which you cannot do with type casting. The data will be copied at some point.
Edit:
What you want to do is possible with ByteBuffer.allocateDirect , ByteBuffer.asFloatBuffer and GetDirectBufferAddress . In Java, you can use a FloatBuffer to interpret the data as a float, and the array will be available directly in native code using GetDirectBufferAddress . I sent an answer to your other question as an additional explanation.
source share