About: 8920 results

JNI - native method with ByteBuffer parameter - Stack Overflow
https://stackoverflow.com/questions/2673839/jni-na ...
Assuming you allocated the ByteBuffer using ByteBuffer.allocateDirect() you can use GetDirectBufferAddress jbyte* bbuf_in; jbyte* bbuf_out; bbuf_in = (*env)-> GetDirectBufferAddress(env, buf1); bbuf_out= (*env)->GetDirectBufferAddress( env, ...
How to send Java ByteBuffer to C using JNI? - Stack Overflow
https://stackoverflow.com/questions/47175310/how-t ...
To use GetDirectBufferAddress() you must guarantee that pkt is direct (you can check this with isDirect()). The easy way to obtain such object is ByteBuffer. allocateDirect() . Direct ByteBuffer can be created from C++, too.
Manipulation of ByteBuffer from JNI - Stack Overflow
https://stackoverflow.com/questions/11329519/manip ...
You could let your native method return the number of written bytes. Then update the ByteBuffer accordingly on the Java side. public class SomeClass { /** * @ param buffer input/output buffer * @return number of bytes written ...
JNI GetDirectBufferAddress vs. ByteBuffer.array() - Stack Overflow
https://stackoverflow.com/questions/37415524/jni-g ...
ByteBuffer class is indeed confusing. It is actually a wrapper around one of two entirely different classes: DirectByteBuffer and ArrayByteBuffer. Why this happened, is a question for historians. As far as the programmers are ...
Returning bytebuffer from jni is copy or reference? - Stack Overflow
https://stackoverflow.com/questions/34460860/retur ...
Java guide NewDirectByteBuffer. Allocates and returns a direct java.nio. ByteBuffer referring to the block of memory starting at the memory address address and extending capacity bytes. Native code that calls this function and ...
JNI ByteBuffer put bytes - Stack Overflow
https://stackoverflow.com/questions/12322964/jni-b ...
The method signature (I, B)Ljava/nio/ByteBuffer is wrong. There is no , between arguments in method signatures and classes are L<class>; (you forgot the ; ). So the correct signature is: (IB)Ljava/nio/ByteBuffer;. Then the code ...
JNI - Free ByteBuffer from C++ - Stack Overflow
https://stackoverflow.com/questions/14751527/jni-f ...
You don't need to release the buffer. You have allocated it on Java side, which means it's JVM object and GC will take care about it. As contrary to allocating on C side, thus being a native object which GC doesn't know about.
How to convert char[] to ByteBuffer in JNI? - Stack Overflow
https://stackoverflow.com/questions/9477821/how-to ...
How was the ByteBuffer created? Is it a direct or non-direct ByteBuffer? If it's a direct ByteBuffer which has been created in Java using the allocateDirect method you can us GetDirectBufferAddress in your native code to get the direct address of ...
java - JNI ByteBuffer put bytes - Stack Overflow
https://stackoverflow.com/questions/12322964/jni-b ...
JNIEXPORT jboolean JNICALL Java_directshowcamera_dsInterface_grab_1frame_1stream(JNIEnv *env, jobject obj, jint streamid, jobject barray) { jclass bbclass = env->FindClass( "java/ nio/ByteBuffer" ); jmethodID putMethod ...
JNI Enhancements in Java SE
https://docs.oracle.com/javase/8/docs/technotes/gu ...
ByteBuffer class. Three new functions allow JNI code to create, examine, and manipulate direct buffers: NewDirectByteBuffer; GetDirectBufferAddress; GetDirectBufferCapacity. Every implementation of the Java virtual machine must support ...