summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <[email protected]>2024-11-13 14:27:00 +0100
committerVolker Hilsheimer <[email protected]>2024-11-25 11:39:34 +0100
commit1a2ffdc9b6de3e4487ada7a50cefb0882ea25fe9 (patch)
tree4bc59a9ee41b5df4e0b9639b1e0ee5210184ecd6
parent4de9b94042dd173c6db31a4641a1513a9b319a79 (diff)
QJniArray: find the java/lang/String class from the cache
Don't look it up through JNIEnv::FindString, use our internal cache. For that (and as we don't want to instantiate a temporary QJniEnvironment) we need to use the QtAndroidPrivate internal symbol, which then needs to be forward declared. Change-Id: I4a69bf973fbdc1df6939f5ce94878588a4fcbd3d Reviewed-by: Assam Boudjelthia <[email protected]> Reviewed-by: Soheil Armin <[email protected]>
-rw-r--r--src/corelib/kernel/qjniarray.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/kernel/qjniarray.h b/src/corelib/kernel/qjniarray.h
index cd85ae48043..68268790632 100644
--- a/src/corelib/kernel/qjniarray.h
+++ b/src/corelib/kernel/qjniarray.h
@@ -24,6 +24,12 @@ QT_BEGIN_NAMESPACE
template <typename T> class QJniArray;
template <typename T> struct QJniArrayMutableIterator;
+// forward declare here so that we don't have to include the private header
+namespace QtAndroidPrivate
+{
+ Q_CORE_EXPORT jclass findClass(const char *className, JNIEnv *env);
+}
+
template <typename T>
struct QJniArrayIterator
{
@@ -915,7 +921,7 @@ auto QJniArrayBase::makeObjectArray(List &&list)
std::is_base_of<QtJniTypes::JObjectBase, ElementType>>) {
elementClass = std::begin(list)->objectClass();
} else if constexpr (std::is_same_v<ElementType, QString>) {
- elementClass = env->FindClass("java/lang/String");
+ elementClass = QtAndroidPrivate::findClass("java/lang/String", env);
} else {
elementClass = env->GetObjectClass(*std::begin(list));
}