We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50cb278 commit f2bd0e2Copy full SHA for f2bd0e2
include/jni/class.hpp
@@ -108,6 +108,15 @@ namespace jni
108
return Class(FindClass(env, TagType::Name()));
109
}
110
111
+ static const Class& Singleton(JNIEnv& env)
112
+ {
113
+ // The global references created here is purposefully leaked. Due to the design
114
+ // of Java/JNI, there is virtually no way to reliably release them. See
115
+ // http://bleaklow.com/2006/02/18/jni_onunload_mostly_useless.html for details.
116
+ static Class singleton = Find(env).NewGlobalRef(env).release();
117
+ return singleton;
118
+ }
119
+
120
template < class... Args >
121
Constructor<TagType, Args...> GetConstructor(JNIEnv& env) const
122
{
0 commit comments