From d41ae1a9a8cd15619e9c47120390ad27144abdeb Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 31 May 2024 16:13:14 +0200 Subject: [PATCH] JNI: Fix static_assert for type registrations Types signatures have to start with either "[L" (array of class) or "L" (just class), and end with ";". Only "[" (array of primitive type) makes no sense, esp since we also require a terminating ";". Change-Id: Iea9ce992c31a34639016c967f813ebf9343c6978 Reviewed-by: Assam Boudjelthia --- src/corelib/kernel/qjnitypes.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qjnitypes.h b/src/corelib/kernel/qjnitypes.h index e071a3f7844..576ce511563 100644 --- a/src/corelib/kernel/qjnitypes.h +++ b/src/corelib/kernel/qjnitypes.h @@ -27,12 +27,12 @@ template<> \ struct QtJniTypes::Traits { \ static constexpr auto signature() \ { \ - static_assert((Signature[0] == 'L' \ - || Signature[0] == '[') \ - && Signature[sizeof(Signature) - 2] == ';', \ + constexpr QtJniTypes::CTString sig(Signature); \ + static_assert((sig.startsWith('L') || sig.startsWith("[L")) \ + && sig.endsWith(';'), \ "Type signature needs to start with 'L' or" \ - " '[' and end with ';'"); \ - return QtJniTypes::CTString(Signature); \ + " '[L', and end with ';'"); \ + return sig; \ } \ }; \