MCPcopy Create free account
hub / github.com/Snapchat/Valdi / JavaEnv

Class JavaEnv

valdi_core/src/valdi_core/jni/JavaEnv.hpp:29–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27};
28
29class JavaEnv {
30public:
31 JavaEnv();
32
33 static void setExceptionHandlerForCurrentThread(JNIExceptionHandler* exceptionHandler);
34 static JNIExceptionHandler* getExceptionHandlerForCurrentThread();
35
36 static JNIEnv* getUnsafeEnv();
37
38 template<typename Fun>
39 static auto accessEnv(Fun&& f) {
40 f(*getUnsafeEnv());
41 checkException();
42 }
43
44 template<typename Fun>
45 static auto accessEnvRet(Fun&& f) {
46 auto result = f(*getUnsafeEnv());
47 checkException();
48 return result;
49 }
50
51 template<typename Fun>
52 static auto accessEnvRetRef(Fun&& f) -> ::djinni::LocalRef<decltype(f(*getUnsafeEnv()))> {
53 auto result = f(*getUnsafeEnv());
54 if (result == nullptr) {
55 checkException();
56 }
57 return ::djinni::LocalRef<decltype(f(*getUnsafeEnv()))>(result);
58 }
59
60 static bool checkException();
61
62 static JavaCache& getCache();
63
64 static ::djinni::GlobalRef<jobject> newGlobalRef(jobject obj);
65 static ::djinni::GlobalRef<jclass> newGlobalRef(jclass cls);
66 static ::djinni::LocalRef<jobject> newLocalRef(jobject obj);
67
68 static bool instanceOf(jobject object, const JavaClass& cls);
69 static bool isSameObject(jobject object, jobject otherObject);
70};
71
72} // namespace ValdiAndroid

Callers 15

toValueMethod · 0.70
toObjectMethod · 0.70
getEnvMethod · 0.70
~GlobalRefJavaObjectMethod · 0.70
getEnvMethod · 0.70
makeMethodInvokerFunction · 0.70
fromReflectedMethodMethod · 0.70
getWeakReferenceValueFunction · 0.70
getEnvMethod · 0.70

Calls

no outgoing calls

Tested by 2

toCppMethod · 0.40
fromCppMethod · 0.40