QJniObject: specialize the QtJniTypes::Traits to treat it like jobject

It doesn't make a lot of sense to pass QJniObject instances into APIs,
but to be able to consistently treat QJniObject as an object type we
have to register it with the java/lang/Object signature.

Change-Id: Ic40e2676186bf327fa92764da51404985f74b565
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 82254fa836a21b5ec450a4ec7635e72403dded18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-07-14 12:42:41 +02:00 committed by Qt Cherry-pick Bot
parent 6c3513f514
commit 43f0b1fcee
2 changed files with 15 additions and 9 deletions

View File

@ -825,6 +825,21 @@ template <typename T> struct Traits<JObject<T>> {
static constexpr auto signature() { return Traits<T>::signature(); }
static constexpr auto className() { return Traits<T>::className(); }
};
template<>
struct Traits<QJniObject>
{
static constexpr auto className()
{
return CTString("java/lang/Object");
}
static constexpr auto signature()
{
return CTString("Ljava/lang/Object;");
}
};
}
// This cannot be included earlier as QJniArray is a QJniObject subclass, but it

View File

@ -35,15 +35,6 @@ struct QtJniTypes::Traits<QtJavaWrapper>
}
};
template<>
struct QtJniTypes::Traits<QJniObject>
{
static constexpr auto signature()
{
return QtJniTypes::CTString("Ljava/lang/Object;");
}
};
struct QtCustomJniObject : QJniObject {};
template<>