I have a C++ library that uses a struct which contains a vector. I am having some difficulty determining the correct way to access this from Java via JNA.
My C++ structure:
#include <vector> struct topic { char* src_id; char* dest_id; int32_t num; std::vector<char*> names; }; My Java class:
public final class Topic extends Structure { public String src_id; public String dest_id; public int num; public String[] names; // This doesn't work public Topic() { } @Override protected List<String> getFieldOrder() { return Arrays.asList(new String[] { "src_id", "dest_id", "num", "names" }); } }
Vectorin c++ but an array in java, what happens when you use an array in c++ too?ArrayListin java, my thought behind the array thing was, that I am not entirely sure, that JNI will know how to directly convert from astd::vectorto an array. Just a speculation though