Is it possible to access the object link of a JNI object in Java Layer?
Yes, you can. However, you cannot use it to access its properties. You can save your address only as long .
If you want to do this, you must create your C ++ objects in heap memory and return them as long numbers.
MyClass *obj = new MyClass(); return (long) obj;
On the Java side, you can save this address as long wherever you want. Because objects were created in heap memory, they will remain valid between JNI calls.
In addition, you must pass them to later JNI calls as a long number, and then you must forward them to MyClass * on the C ++ side.
MyClass *obj = (MyClass *)thatLongNumber; obj->someProperty;
Hi I'm Frogatto Oct 06 '15 at 10:40 2015-10-06 10:40
source share