I'm currently using the JNI to interface with a library I built, but the library depends on the state of an object and is intended to invoke methods on the object to do work. How can I keep this object in memory without making it be global in the .cpp
file interfacing the JNI?
What I would like it to look like is something like this:
public class Consumer {
public NativeType workerObject;
public native void methodOneToCallOnWorker();
public native void methodTwoToCallOnWorker();
...
}
Is there a way to keep workerObject
in state without making it global?