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

Function JNI_OnLoad

libs/utils/src/utils/platform/JvmUtils.cpp:49–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48// Called when library is loaded by the first class which uses it.
49extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved) // NOLINT naming
50{
51 debugging::ScopedTrace trace("client::JNI_OnLoad");
52 gJvm = jvm;
53 djinni::jniInit(jvm);
54
55 [[maybe_unused]] auto result = pthread_key_create(&gJniPtr, &threadDestructor);
56 SC_ASSERT(!result);
57
58 JNIEnv* jni = nullptr;
59 if (jvm->GetEnv(reinterpret_cast<void**>(&jni), JNI_VERSION_1_6) != JNI_OK)
60 return -1;
61
62 jni::runOnLoadInitializers(jni);
63
64 return JNI_VERSION_1_6;
65}
66
67// (Potentially) called when library is about to be unloaded.
68extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* jvm, void* reserved) // NOLINT naming

Callers

nothing calls this directly

Calls 2

jniInitFunction · 0.85
runOnLoadInitializersFunction · 0.85

Tested by

no test coverage detected