I want to return an object from c++ to java code using JNI.
I don’t need to use its methods, but just read its fields.
How can I do it?
This class is just something like this:
class MyOutputClass
{
public:
Array<SomeOtherClass> m_objects1;
Array<YetAnoterClass> m_objects2;
}
Array is a class of mine, but i’ll use the java array instead 🙂
If you want to pass a C++ object to Java you can’t.
But you can create a Java object in native and then return this from your native method.
That would be done like this:
You can either pass your data in the ctor or access the fields of your object and change them. BTW. I did not compile the code above. But it should not contain too many errors.