I have a native function :
int NativeFunction(std::vector<MyObject>);
I am loading the Native dll using JNA and I am trying to call this function NativeFunction from Java like:
nativedlljnapointer.NativeFunction(List<MyObject>);
I am however running into "java.lang.IllegalArgumentException: Unsupported argument type ArrayList" exception.
I al tried using java util vector when I am running into the same exception "java.lang.IllegalArgumentException: Unsupported argument type java.util.Vector"
Can someone suggest me how I could pass List from my Java function to the native function which has vector<> as an argument.
Any help will be greatly appreciated.
std::vector and java List are completely different types, it's normal for them not to work.
Furthermore , Is MyObject a C++ defined object or a Java defined object (if you define one in each, they are again, completely different objects ! )?
The best and safest way to communicate via JNI is to use serialization, like you would between any two different environments.
Granted, it takes a bit of extra work, but in the long run you end up with more robust code.