I think I have an idea of what to do, I just wanted to poke the SO community to see if I'm on the right track as I haven't seen any information about this specific topic from my research.
I have some custom Java (data model) classes that I want to be accessible on my native C++ side of my application. I realize that these two environments are fairly separate, so I'll have to most likely create a "copy" of my data models in c++, and initialize them in my nativeLib JNI file?
I'm assuming I can't just "convert" the java class to the c++ class, since the compiler probably won't be able to do such a conversion. I'll have to manage each of the fields that I need manually through a JNI method call.
Is this correct, or is there a better way that I'm not aware of?
I suppose an example might look like this:
Foo.java
public class Foo {
boolean A;
boolean B;
boolean C;
}
native-lib.cpp
extern "C" {
std::unique_ptr<Foo> foo;
JNIEXPORT void JNICALL
Java_com_example_user_project_native_1Foo(JNIEnv *env, jobject instance, jbool jbooleanA, jbool jbooleanB, jbool jbooleanC) {
Foo->setA(jbooleanA);
Foo->setB(jbooleanB);
Foo->setC(jbooleanC);
}
Foo.h
class Foo {
private:
bool A;
bool B;
bool C;
public:
// add setters & getters here, or any other needed functions
}