Android: Fix crash caused by QJNIs classLoader code.

In some cases the classLoader is not able to resolve fully-qualified
names that contains forward slashes. Unlike FindClass() which expects
the fully-qualified name to contain slashes, the classLoader expects
the binary name, i.e., with '.' as separator.

This caused a crash in QtMultimedia when accessing a nested class.

Task-number: QTBUG-35298
Change-Id: I77728352fbab930ae1914bc1cb2189e458e179e2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Christian Strømme 2013-12-02 14:56:50 +01:00 committed by The Qt Project
parent 6c5febd203
commit 483806f35f

View File

@ -74,7 +74,8 @@ static jclass getCachedClass(JNIEnv *env, const char *className)
if (!classLoader.isValid())
return 0;
QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(QLatin1String(className));
QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(QString::fromLatin1(className).replace(QLatin1Char('/'),
QLatin1Char('.')));
QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object());