I'm loading a C DLL from a program written in Java. I want to be able to call one of the methods from the DLL with this declaration :
dll_function(const char* foo1, const char* foo2, const char* foo3, void** bar, size_t* bar2);
How do I call this method with arguments of correct type in Java ? I know (theorically) how to call it, but what I would like to know is how to pass the "void**" and "size_t*" from my Java program ? Basically, I want to know what the "equivalent type" for void and size_t*** is in Java...
I found the Pointer class but didn't manage to get it work ? Many thanks :)
I worked on a Java/JNI/C project several years ago, and we had to maintain opaque C pointers within Java objects. We used long
values on the Java side to hold the C pointers, which were converted on the JNI side from jlong
to void*
or whatever pointer type we needed.
Since the Java long
type is 64 bits wide, and JNI/C pointers are typically either 32 bits or 64 bits wide, we did not have any problems converting between them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With