As fadden advised me, I used a ByteBuffer.
----------------------------------------------------------------------------
ByteBuffer myBuffer = ByteBuffer.allocateDirect(128);
myBuffer.put(0,(byte) 51);
myBuffer.put(1,(byte) 49);
----------------------------------------------------------------------------
In my native code, I want to return the 'first element' of the buffer, that's to say : 51.
-------------------------------------------------------------------------------------------
jint
Java_com_example_twolibs_TwoLibs_sum( JNIEnv * env,
jobject this,
jobject buff )
{
jbyte *BUFF = (*env)->GetDirectBufferAddress(env, buff);
return BUFF[0];
}
-----------------------------------------------------------------------------------------
Well, that function returns 12595! That's because:
* 51 = 00110001
* 49 = 00110011
* 12595 = 0011000100110011
How can I get only 1 byte instead of all the content of the buffer?