JNI - sending class instances to C++ -


i want send struct-like object java c++. since there no structs in java guess have write class , send instance of class.

public class soundsource {      int posx;      int posy;      ..... } 

but... jobject jni method in c++ - how extract individual fields?

thanks

dennis's answer correct, however, there's way can this, might give better performance, , via direct byte-buffers.

here docs need read: jni nio support, bytebuffer

you allocate direct byte-buffer either on java side or c side. populate buffer, on java side, using bytebuffer's methods, according c-struct's layout. remember these buffers must deallocated when you're done using them, can reuse same buffer pass data back-and-forth.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -