From 514fb99b54e874602c5ff1f69702d2d604ea3cd6 Mon Sep 17 00:00:00 2001 From: Denis Slynko Date: Tue, 3 Jun 2025 18:15:08 +0300 Subject: [PATCH] [ANI] Fix signatures of Record methods Fix signatures of `escompat.Record` methods `$_get` and `$_set` which are used through ANI. The changes are required due to introduction of union descriptor in ArkTS runtime, which makes union types being non-erased during compilation Issue: #ICB6V0 Change-Id: I9edd4183178431031c8105ca9f93879883e322ac Signed-off-by: Denis Slynko --- .../src/ets_ability_delegator_utils.cpp | 5 +++-- .../ets/ani/ani_common/include/ani_common_util.h | 10 ++++++++++ .../form_extension_ability/src/sts_form_extension.cpp | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp b/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp index 8454abe7e4d..37f04590618 100644 --- a/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp +++ b/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp @@ -16,6 +16,7 @@ #include "ets_ability_delegator_utils.h" #include +#include "ani_common_util.h" #include "ets_ability_delegator.h" #include "hilog_tag_wrapper.h" @@ -134,13 +135,13 @@ void SetParameters(ani_env *aniEnv, ani_class arguments, ani_object argumentObje return; } ani_method recordGetMethod; - status = aniEnv->Class_FindMethod(recordCls, "$_get", "Lstd/core/Object;:Lstd/core/Object;", &recordGetMethod); + status = aniEnv->Class_FindMethod(recordCls, "$_get", GetRecordGetSignature(), &recordGetMethod); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Class_FindMethod failed status: %{public}d", status); return; } ani_method recordSetMethod; - status = aniEnv->Class_FindMethod(recordCls, "$_set", "Lstd/core/Object;Lstd/core/Object;:V", &recordSetMethod); + status = aniEnv->Class_FindMethod(recordCls, "$_set", GetRecordSetSignature(), &recordSetMethod); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Class_FindMethod failed status: %{public}d", status); return; diff --git a/frameworks/ets/ani/ani_common/include/ani_common_util.h b/frameworks/ets/ani/ani_common/include/ani_common_util.h index 6c04d37037f..6a4b8a7fff6 100644 --- a/frameworks/ets/ani/ani_common/include/ani_common_util.h +++ b/frameworks/ets/ani/ani_common/include/ani_common_util.h @@ -22,6 +22,16 @@ namespace OHOS { namespace AppExecFwk { +inline constexpr const char *GetRecordGetSignature() +{ + return "X{C{std.core.Numeric}C{std.core.String}}:C{std.core.Object}"; +} + +inline constexpr const char *GetRecordSetSignature() +{ + return "X{C{std.core.Numeric}C{std.core.String}}C{std.core.Object}:"; +} + bool GetDoubleOrUndefined(ani_env *env, ani_object param, const char *name, ani_double &value); bool GetBoolOrUndefined(ani_env *env, ani_object param, const char *name); bool GetStringOrUndefined(ani_env *env, ani_object param, const char *name, std::string &res); diff --git a/frameworks/ets/ani/form_extension_ability/src/sts_form_extension.cpp b/frameworks/ets/ani/form_extension_ability/src/sts_form_extension.cpp index c8ccbbadf84..ab1d83e22fd 100644 --- a/frameworks/ets/ani/form_extension_ability/src/sts_form_extension.cpp +++ b/frameworks/ets/ani/form_extension_ability/src/sts_form_extension.cpp @@ -20,6 +20,7 @@ #include "ability_info.h" #include "ani.h" +#include "ani_common_util.h" #include "ani_common_want.h" #include "form_provider_data.h" #include "form_runtime/form_extension_provider_client.h" @@ -584,7 +585,7 @@ bool STSFormExtension::CreateAndFillRecordObject(ani_env *env, const std::mapClass_FindMethod(recordCls, "$_set", "Lstd/core/Object;Lstd/core/Object;:V", &recordSetMethod); + status = env->Class_FindMethod(recordCls, "$_set", GetRecordSetSignature(), &recordSetMethod); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::FORM_EXT, "Class_FindMethod set failed: %{public}d", status); return false; -- Gitee