Android: don't call JNI_OnLoad for libraries opened with QLibrary
JNI_OnLoad gets called automatically by the JVM when it loads a shared library. A native library that is loaded by native code shouldn't have it's JNI_OnLoad entry point function called, as that would indicate that the plugin is loaded by the JVM, which it is not. If framework or application code requires that function to be called (and wants to perform error handling, such as closing the library again if the function returns JNI_ERR), then that can and should be done explicitly. [ChangeLog][Android][QLibrary] Loading a shared library with QLibrary no longer implicily calls a JNI_OnLoad implementation. Fixes: QTBUG-92007 Pick-to: 6.7 Change-Id: I9aa71ec73b950029e0ae1be7d54e1c8576f356ab Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>bb10
parent
8ba043cbaf
commit
359df32300
|
|
@ -207,14 +207,6 @@ bool QLibraryPrivate::load_sys()
|
|||
auto attemptFromBundle = attempt;
|
||||
hnd = dlopen(QFile::encodeName(attemptFromBundle.replace(u'/', u'_')), dlFlags);
|
||||
}
|
||||
if (hnd) {
|
||||
using JniOnLoadPtr = jint (*)(JavaVM *vm, void *reserved);
|
||||
JniOnLoadPtr jniOnLoad = reinterpret_cast<JniOnLoadPtr>(dlsym(hnd, "JNI_OnLoad"));
|
||||
if (jniOnLoad && jniOnLoad(QJniEnvironment::javaVM(), nullptr) == JNI_ERR) {
|
||||
dlclose(hnd);
|
||||
hnd = nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!hnd && fileName.startsWith(u'/') && QFile::exists(attempt)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue