I have code that is implementing an observer pattern in C++. I have created Java JNI code that is similar to C++ code to register an observer. When I register an observer in Java, it calls a native method that create a listener in C++.
I want the method calls in C++ to call the equivalent methods in my Java observer that is registered. I have created code for this by passing the JNIEnv to the observer class in C++, but I've heard this isn't safe. Is there a best practice on this type of implementation?