JNI - native method with ByteBuffer parameter

前端 未结 1 1714
谎友^
谎友^ 2020-12-24 03:00

I\'ve got a method:

public native void doSomething(ByteBuffer in, ByteBuffer out);

Generated by javah C/C++ header of this method is:

相关标签:
1条回答
  • 2020-12-24 03:19

    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, buf2); 
    
    0 讨论(0)
提交回复
热议问题