I have a function in C++:
std::vector<std::vector<float>> const &GetVertices() { return m_Vertices; } I need to return this value to Java through JNI.
So, because of the fact that I need to return vector of vector, I think that I have to use jobjectArray, like this:
extern "C" JNIEXPORT jobjectArray JNICALL Java_com_google_ar_core_examples_ java_helloar_HelloArActivity_fillListWithData( JNIEnv *env, jobject /* this */ ) In Java, I have this method:
public native Object[] fillListWithData(); So, my question is, how to convert vector<vector<float>> to jobjectArray?
I know that there is a method that could create jobjectArray:
jobjectArray verticesArr = env->NewObjectArray(verticesVec.size(), WHAT CLASS SHOULD BE HERE?,NULL); Then how can I put in the values ?
Full class implementation
extern "C" JNIEXPORT jobjectArray JNICALL Java_com_google_ar_core_examples_java_ helloar_HelloArActivity_fillListWithData( JNIEnv *env, jobject /* this */ ) { //verticesVec vector<vector<float>> verticesVec = initializer->GetVertices(); // THIS VECTOR I NEED TO CONVERT TO JOBJECTARRAY jobjectArray verticesArr = env->NewObjectArray(verticesVec.size(), WHAT CLASS SHOULD BE HERE?,NULL); //HOW TO FILL THE ARRAY HERE?? return verticesArr; }