From d2f950e88f6f3966e5593e06f307959d12c19ec8 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 14 Sep 2023 19:11:48 +0200 Subject: [PATCH] JNI: fix isObjectType trait function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Java arrays are always objects, also if they don't contain objects. Pick-to: 6.6 Change-Id: I376c9cc39445d7d9aaac093e4cd6995c8322ed0d Reviewed-by: Petri Virkkunen Reviewed-by: Tinja Paavoseppä Reviewed-by: Zoltan Gera --- src/corelib/kernel/qjnitypes_impl.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qjnitypes_impl.h b/src/corelib/kernel/qjnitypes_impl.h index a7a3a30b2a..97be4f4394 100644 --- a/src/corelib/kernel/qjnitypes_impl.h +++ b/src/corelib/kernel/qjnitypes_impl.h @@ -243,6 +243,13 @@ static constexpr bool isPrimitiveType() return typeSignature().size() == 2; } +template +static constexpr bool isArrayType() +{ + constexpr auto signature = typeSignature(); + return signature.startsWith('[') && signature.size() > 2; +} + template static constexpr bool isObjectType() { @@ -250,18 +257,10 @@ static constexpr bool isObjectType() return true; } else { constexpr auto signature = typeSignature(); - return (signature.startsWith('L') || signature.startsWith('[')) - && signature.endsWith(';'); + return (signature.startsWith('L') && signature.endsWith(';')) || isArrayType(); } } -template -static constexpr bool isArrayType() -{ - constexpr auto signature = typeSignature(); - return signature.startsWith('['); -} - template static constexpr void assertObjectType() {