Search code examples
javac++java-native-interface

JNI -> how to wrap c++ void*


I have c++ function that take void* as parameter. How to wrap it in java?

C++

void foo(void* data)
{
}

Java

void foo(Object[] data)
{
}

I'm not sure. Please help.


Solution

  • The closest I can think (I'm not so well versed in the language) of in java code is

    void foo(Byte[] data) {
    }
    

    Though you don't know the actual size of the byte array, this needs to be clear from the foo() function called via JNI.