jmethodID initMid;
if (sdk_int < __ANDROID_API_Q__) {
initMid = JNI_GetMethodID(env, in_memory_classloader, "<init>",
"([Ljava/nio/ByteBuffer;Ljava/lang/ClassLoader;)V");
} else {
initMid = JNI_GetMethodID(env, in_memory_classloader, "<init>",
"([Ljava/nio/ByteBuffer;Ljava/lang/String;Ljava/lang/ClassLoader;)V");
}
auto byte_buffer_class = JNI_FindClass(env, "java/nio/ByteBuffer");
auto dex_buffer = env->NewDirectByteBuffer(dex_data, dex_size);
auto dex_buffer_array = JNI_NewObjectArray(env, 1, byte_buffer_class, dex_buffer);
if (sdk_int < __ANDROID_API_Q__) {
if (auto my_cl = JNI_NewObject(env, in_memory_classloader, initMid,
dex_buffer_array, sys_classloader)) {
inject_class_loader_ = JNI_NewGlobalRef(env, my_cl);
}
} else {
jstring librarySearchPath = nullptr;
if (auto my_cl = JNI_NewObject(env, in_memory_classloader, initMid,
dex_buffer_array, librarySearchPath, sys_classloader)) {
inject_class_loader_ = JNI_NewGlobalRef(env, my_cl);
}
}