You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Class and Object helpers in JavaWrappers were updated to restrict external access to the m_class and m_object internal members. The goal is to ensure when setting the member variables to a new jobject it using a global JNI ref (through calling env->NewGlobalRef). Doing so protects external classes and child classes from instantiating local JNI references that may become stale before the lifetime of the wrapper object. It does not however protect the Class and Object wrappers from misusing the jobject references.
Instead of making Class and Object aware of the need to create a global JNI reference a new templated class should be created to store the jobject reference and ensure we're creating global references. The Class and Object wrappers could then use that new container for their jclass and jobject member variables and remove the duplicated responsibility of maintaining global references.
Alternatively it might warrant looking into using the fbjni wrapper library instead of the custom JavaWrappers implementation.
The text was updated successfully, but these errors were encountered:
CoPrez
changed the title
Simplify JClass and JObject wrappers
Simplify Class and Object JNI wrappers
Jul 20, 2022
In this PR:
#1101
The Class and Object helpers in JavaWrappers were updated to restrict external access to the m_class and m_object internal members. The goal is to ensure when setting the member variables to a new jobject it using a global JNI ref (through calling env->NewGlobalRef). Doing so protects external classes and child classes from instantiating local JNI references that may become stale before the lifetime of the wrapper object. It does not however protect the Class and Object wrappers from misusing the jobject references.
Instead of making Class and Object aware of the need to create a global JNI reference a new templated class should be created to store the jobject reference and ensure we're creating global references. The Class and Object wrappers could then use that new container for their jclass and jobject member variables and remove the duplicated responsibility of maintaining global references.
Alternatively it might warrant looking into using the fbjni wrapper library instead of the custom JavaWrappers implementation.
The text was updated successfully, but these errors were encountered: