From b87d3c3dcde6b4aa894f9d964f144954ce081c03 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 30 Jun 2025 16:23:15 +0300 Subject: [PATCH] ANI: Remove deprecated 'Class_Find*' APIs Issue: #ICIY7C List of removed APIs: - Class_FindSetter() - Class_FindGetter() - Class_FindIndexxableSetter() - Class_FindIndexableGetter() - Class_FindIterator() Signed-off-by: Vyacheslav Cherkashin --- static_core/plugins/ets/runtime/ani/ani.h | 84 ------------- .../ets/runtime/ani/ani_interaction_api.cpp | 50 +------- .../plugins/ets/runtime/ani/docs/ani.md | 59 --------- .../stdlib/native/core/IntlDateTimeFormat.cpp | 3 +- .../native/core/IntlRelativeTimeFormat.cpp | 10 +- .../arraybuffer_get_info_test.cpp | 2 +- .../tests/ani/tests/class_ops/CMakeLists.txt | 15 --- ...lass_find_indexable_getter_setter_test.cpp | 86 ------------- ...lass_find_indexable_getter_setter_test.ets | 24 ---- .../class_ops/class_find_iterator_test.cpp | 77 ------------ .../class_ops/class_find_iterator_test.ets | 70 ----------- .../class_ops/class_find_method_test.cpp | 112 ++++++++++++++++- .../class_ops/class_find_method_test.ets | 112 ++++++++++++++++- .../class_find_setter_getter_test.cpp | 116 ------------------ .../class_find_setter_getter_test.ets | 48 -------- .../tests/error_ops/error_handling_test.cpp | 4 +- .../tests/mangling/mangle_signature_test.cpp | 36 +++--- 17 files changed, 247 insertions(+), 661 deletions(-) delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.cpp delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.ets delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.cpp delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.ets delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.cpp delete mode 100644 static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.ets diff --git a/static_core/plugins/ets/runtime/ani/ani.h b/static_core/plugins/ets/runtime/ani/ani.h index ac81ebec47..0ae3b421bd 100644 --- a/static_core/plugins/ets/runtime/ani/ani.h +++ b/static_core/plugins/ets/runtime/ani/ani.h @@ -2553,70 +2553,6 @@ struct __ani_interaction_api { ani_status (*Class_FindStaticMethod)(ani_env *env, ani_class cls, const char *name, const char *signature, ani_static_method *result); - /** - * @brief Finds a setter method from by its name. - * - * This function locates a setter method based on its name and stores it in the result parameter. - * - * @param[in] env A pointer to the environment structure. - * @param[in] cls The class to query. - * @param[in] name The name of the property whose setter is to be found. - * @param[out] result A pointer to the method to be populated. - * @return Returns a status code of type `ani_status` indicating success or failure. - */ - ani_status (*Class_FindSetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); - - /** - * @brief Finds a getter method from by its name. - * - * This function locates a getter method based on its name and stores it in the result parameter. - * - * @param[in] env A pointer to the environment structure. - * @param[in] cls The class to query. - * @param[in] name The name of the property whose getter is to be found. - * @param[out] result A pointer to the method to be populated. - * @return Returns a status code of type `ani_status` indicating success or failure. - */ - ani_status (*Class_FindGetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); - - /** - * @brief Finds an indexable getter method from by its signature. - * - * This function locates an indexable getter method based on its signature and stores it in the result parameter. - * - * @param[in] env A pointer to the environment structure. - * @param[in] cls The class to query. - * @param[in] signature The signature of the indexable getter to find. - * @param[out] result A pointer to the method to be populated. - * @return Returns a status code of type `ani_status` indicating success or failure. - */ - ani_status (*Class_FindIndexableGetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); - - /** - * @brief Finds an indexable setter method from by its signature. - * - * This function locates an indexable setter method based on its signature and stores it in the result parameter. - * - * @param[in] env A pointer to the environment structure. - * @param[in] cls The class to query. - * @param[in] signature The signature of the indexable setter to find. - * @param[out] result A pointer to the method to be populated. - * @return Returns a status code of type `ani_status` indicating success or failure. - */ - ani_status (*Class_FindIndexableSetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); - - /** - * @brief Finds an iterator method. - * - * This function locates an iterator method - * - * @param[in] env A pointer to the environment structure. - * @param[in] cls The class to query. - * @param[out] result A pointer to the method to be populated. - * @return Returns a status code of type `ani_status` indicating success or failure. - */ - ani_status (*Class_FindIterator)(ani_env *env, ani_class cls, ani_method *result); - /** * @brief Retrieves a boolean value from a static field of a class. * @@ -7032,26 +6968,6 @@ struct __ani_env { { return c_api->Class_FindStaticMethod(this, cls, name, signature, result); } - ani_status Class_FindSetter(ani_class cls, const char *name, ani_method *result) - { - return c_api->Class_FindSetter(this, cls, name, result); - } - ani_status Class_FindGetter(ani_class cls, const char *name, ani_method *result) - { - return c_api->Class_FindGetter(this, cls, name, result); - } - ani_status Class_FindIndexableGetter(ani_class cls, const char *signature, ani_method *result) - { - return c_api->Class_FindIndexableGetter(this, cls, signature, result); - } - ani_status Class_FindIndexableSetter(ani_class cls, const char *signature, ani_method *result) - { - return c_api->Class_FindIndexableSetter(this, cls, signature, result); - } - ani_status Class_FindIterator(ani_class cls, ani_method *result) - { - return c_api->Class_FindIterator(this, cls, result); - } ani_status Class_GetStaticField_Boolean(ani_class cls, ani_static_field field, ani_boolean *result) { return c_api->Class_GetStaticField_Boolean(this, cls, field, result); diff --git a/static_core/plugins/ets/runtime/ani/ani_interaction_api.cpp b/static_core/plugins/ets/runtime/ani/ani_interaction_api.cpp index 2590d66515..654ddfc84b 100644 --- a/static_core/plugins/ets/runtime/ani/ani_interaction_api.cpp +++ b/static_core/plugins/ets/runtime/ani/ani_interaction_api.cpp @@ -2331,21 +2331,6 @@ NO_UB_SANITIZE static ani_status Class_FindStaticMethod(ani_env *env, ani_class return ANI_OK; } -// NOLINTNEXTLINE(readability-identifier-naming) -NO_UB_SANITIZE static ani_status Class_FindIterator(ani_env *env, ani_class cls, ani_method *result) -{ - ANI_DEBUG_TRACE(env); - CHECK_ENV(env); - CHECK_PTR_ARG(cls); - CHECK_PTR_ARG(result); - - EtsMethod *method = nullptr; - ani_status status = GetClassMethod(env, cls, "$_iterator", nullptr, &method); - ANI_CHECK_RETURN_IF_NE(status, ANI_OK, status); - *result = ToAniMethod(method); - return ANI_OK; -} - // NOLINTNEXTLINE(readability-identifier-naming) NO_UB_SANITIZE static ani_status Class_GetStaticField_Boolean(ani_env *env, ani_class cls, ani_static_field field, ani_boolean *result) @@ -2726,34 +2711,6 @@ NO_UB_SANITIZE static ani_status Class_SetStaticFieldByName_Ref(ani_env *env, an return ANI_OK; } -// NOLINTNEXTLINE(readability-identifier-naming) -ani_status Class_FindSetter(ani_env *env, ani_class cls, const char *name, ani_method *result) -{ - PandaString setterName(""); - setterName += name; - return Class_FindMethod(env, cls, setterName.c_str(), nullptr, result); -} - -// NOLINTNEXTLINE(readability-identifier-naming) -ani_status Class_FindGetter(ani_env *env, ani_class cls, const char *name, ani_method *result) -{ - PandaString getterName(""); - getterName += name; - return Class_FindMethod(env, cls, getterName.c_str(), nullptr, result); -} - -// NOLINTNEXTLINE(readability-identifier-naming) -ani_status Class_FindIndexableSetter(ani_env *env, ani_class cls, const char *signature, ani_method *result) -{ - return Class_FindMethod(env, cls, "$_set", signature, result); -} - -// NOLINTNEXTLINE(readability-identifier-naming) -ani_status Class_FindIndexableGetter(ani_env *env, ani_class cls, const char *signature, ani_method *result) -{ - return Class_FindMethod(env, cls, "$_get", signature, result); -} - // NOLINTNEXTLINE(readability-identifier-naming) NO_UB_SANITIZE static ani_status Class_CallStaticMethod_Boolean_V(ani_env *env, ani_class cls, ani_static_method method, ani_boolean *result, va_list args) @@ -3918,7 +3875,7 @@ static ani_status GetErrorDescriptionLines(ani_env *env, ani_error error, ani_st // Get stack trace ani_method getterMethod = nullptr; - status = env->Class_FindGetter(static_cast(errorType), "stack", &getterMethod); + status = env->Class_FindMethod(static_cast(errorType), "stack", nullptr, &getterMethod); ASSERT(status == ANI_OK); ani_ref stackTrace = nullptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) @@ -7098,11 +7055,6 @@ const __ani_interaction_api INTERACTION_API = { Class_FindStaticField, Class_FindMethod, Class_FindStaticMethod, - Class_FindSetter, - Class_FindGetter, - Class_FindIndexableGetter, - Class_FindIndexableSetter, - Class_FindIterator, Class_GetStaticField_Boolean, Class_GetStaticField_Char, Class_GetStaticField_Byte, diff --git a/static_core/plugins/ets/runtime/ani/docs/ani.md b/static_core/plugins/ets/runtime/ani/docs/ani.md index f82ff971c0..f29664991e 100644 --- a/static_core/plugins/ets/runtime/ani/docs/ani.md +++ b/static_core/plugins/ets/runtime/ani/docs/ani.md @@ -737,65 +737,6 @@ result: A pointer to store the retrieved field. **RETURNS:** Returns a status code of type `ani_status` indicating success or failure. -### Class_FindSetter -`ani_status (*Class_FindSetter)(ani_env *env, ani_class cls, const char *name, ani_method *result);` - -**PARAMETERS:** -env: A pointer to the environment structure. -cls: The class to query. -name: The name of the property whose setter is to be retrieved. -result: A pointer to store the retrieved setter method. - -**RETURNS:** -Returns a status code of type `ani_status` indicating success or failure. - -### Class_FindGetter -`ani_status (*Class_FindGetter)(ani_env *env, ani_class cls, const char *name, ani_method *result);` - -**PARAMETERS:** -env: A pointer to the environment structure. -cls: The class to query. -name: The name of the property whose getter is to be retrieved. -result: A pointer to store the retrieved getter method. - -**RETURNS:** -Returns a status code of type `ani_status` indicating success or failure. - -### Class_FindIndexableGetter -`ani_status (*Class_FindIndexableGetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result);` - -**PARAMETERS:** -env: A pointer to the environment structure. -cls: The class to query. -signature: The signature of the indexable getter to retrieve. -result: A pointer to store the retrieved indexable getter method. - -**RETURNS:** -Returns a status code of type `ani_status` indicating success or failure. - -### Class_FindIndexableSetter -`ani_status (*Class_FindIndexableSetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result);` - -**PARAMETERS:** -env: A pointer to the environment structure. -cls: The class to query. -signature: The signature of the indexable setter to retrieve. -result: A pointer to store the retrieved indexable setter method. - -**RETURNS:** -Returns a status code of type `ani_status` indicating success or failure. - -### Class_FindIterator -`ani_status (*Class_FindIterator)(ani_env *env, ani_class cls, ani_method *result);` - -**PARAMETERS:** -env: A pointer to the environment structure. -cls: The class to query. -result: A pointer to store the retrieved iterator method. - -**RETURNS:** -Returns a status code of type `ani_status` indicating success or failure. - ### Object_GetField_Boolean `ani_status (*Object_GetField_Boolean)(ani_env *env, ani_object object, ani_field field, ani_boolean *result);` diff --git a/static_core/plugins/ets/stdlib/native/core/IntlDateTimeFormat.cpp b/static_core/plugins/ets/stdlib/native/core/IntlDateTimeFormat.cpp index 113b0366b3..e5d69e3c8c 100644 --- a/static_core/plugins/ets/stdlib/native/core/IntlDateTimeFormat.cpp +++ b/static_core/plugins/ets/stdlib/native/core/IntlDateTimeFormat.cpp @@ -37,6 +37,7 @@ constexpr const char *FORMAT_HOUR_SYMBOLS = "hHkK"; constexpr const char *FORMAT_AM_PM_SYMBOLS = "a"; constexpr const char *OPTIONS_FIELD_HOUR_CYCLE = "hourCycle"; +constexpr const char *OPTIONS_SETTER_HOUR_CYCLE = "hourCycle"; constexpr const char *LOCALE_KEYWORD_HOUR_CYCLE = "hours"; constexpr const char *LOCALE_KEYWORD_CALENDAR = "calendar"; @@ -723,7 +724,7 @@ static ani_object StdCoreIntlDateTimeFormatFormatResolvedOptionsImpl(ani_env *en ani_string hourCycle = CreateUtf8String(env, localeHours.data(), localeHours.size()); ani_method setter = nullptr; - ANI_FATAL_IF_ERROR(env->Class_FindSetter(optsClass, OPTIONS_FIELD_HOUR_CYCLE, &setter)); + ANI_FATAL_IF_ERROR(env->Class_FindMethod(optsClass, OPTIONS_SETTER_HOUR_CYCLE, nullptr, &setter)); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ANI_FATAL_IF_ERROR(env->Object_CallMethod_Void(resolvedOpts, setter, hourCycle)); diff --git a/static_core/plugins/ets/stdlib/native/core/IntlRelativeTimeFormat.cpp b/static_core/plugins/ets/stdlib/native/core/IntlRelativeTimeFormat.cpp index ac93313084..0665e73fd1 100644 --- a/static_core/plugins/ets/stdlib/native/core/IntlRelativeTimeFormat.cpp +++ b/static_core/plugins/ets/stdlib/native/core/IntlRelativeTimeFormat.cpp @@ -40,7 +40,7 @@ static std::string CallOptionGetter(ani_env *env, ani_object options, const char } ani_method getter = nullptr; - if (env->Class_FindGetter(optionsClass, getterName, &getter) != ANI_OK) { + if (env->Class_FindMethod(optionsClass, getterName, nullptr, &getter) != ANI_OK) { return ""; } @@ -199,8 +199,8 @@ static ani_object StdCoreIntlRelativeTimeFormatResolvedOptionsImpl(ani_env *env, if (env->Object_GetFieldByName_Ref(self, "options", &optionsRef) == ANI_OK && optionsRef != nullptr) { auto options = static_cast(optionsRef); - std::string maybeNumeric = CallOptionGetter(env, options, "numeric"); - std::string maybeStyle = CallOptionGetter(env, options, "style"); + std::string maybeNumeric = CallOptionGetter(env, options, "numeric"); + std::string maybeStyle = CallOptionGetter(env, options, "style"); if (!maybeNumeric.empty()) { numericStr = maybeNumeric; @@ -225,12 +225,12 @@ static ani_object StdCoreIntlRelativeTimeFormatResolvedOptionsImpl(ani_env *env, ANI_FATAL_IF_ERROR(env->Object_New(optsCls, ctor, &resolvedOpts, locale, numberingSystem)); ani_method numericSetter = nullptr; - ANI_FATAL_IF_ERROR(env->Class_FindSetter(optsCls, "numeric", &numericSetter)); + ANI_FATAL_IF_ERROR(env->Class_FindMethod(optsCls, "numeric", nullptr, &numericSetter)); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ANI_FATAL_IF_ERROR(env->Object_CallMethod_Void(resolvedOpts, numericSetter, numeric)); ani_method styleSetter = nullptr; - ANI_FATAL_IF_ERROR(env->Class_FindSetter(optsCls, "style", &styleSetter)); + ANI_FATAL_IF_ERROR(env->Class_FindMethod(optsCls, "style", nullptr, &styleSetter)); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ANI_FATAL_IF_ERROR(env->Object_CallMethod_Void(resolvedOpts, styleSetter, style)); diff --git a/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/arraybuffer_get_info_test.cpp b/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/arraybuffer_get_info_test.cpp index b7352f8138..b0bd7599a1 100644 --- a/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/arraybuffer_get_info_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/arraybuffer_ops/arraybuffer_get_info_test.cpp @@ -159,7 +159,7 @@ TEST_F(ArrayBufferGetInfoTest, GetInfoFromResizableBuffer) ani_class arrayBufferClass {}; ASSERT_EQ(env_->FindClass("Lescompat/ArrayBuffer;", &arrayBufferClass), ANI_OK); ani_method resizableGetter {}; - ASSERT_EQ(env_->Class_FindGetter(arrayBufferClass, "resizable", &resizableGetter), ANI_OK); + ASSERT_EQ(env_->Class_FindMethod(arrayBufferClass, "resizable", nullptr, &resizableGetter), ANI_OK); ani_boolean isResizable = ANI_FALSE; ASSERT_EQ(env_->Object_CallMethod_Boolean(array, resizableGetter, &isResizable), ANI_OK); ASSERT_EQ(isResizable, ANI_TRUE); diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/CMakeLists.txt b/static_core/plugins/ets/tests/ani/tests/class_ops/CMakeLists.txt index a3dcb01ac2..75c2601e1e 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/CMakeLists.txt @@ -16,11 +16,6 @@ ani_add_gtest(ani_test_class_ops_class_find_field ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_field_test.ets ) -ani_add_gtest(ani_test_class_ops_class_get_iterator - CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_iterator_test.cpp - ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_iterator_test.ets -) - ani_add_gtest(ani_test_class_ops_class_find_static_field CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_static_field_test.cpp ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_static_field_test.ets @@ -121,16 +116,6 @@ ani_add_gtest(ani_test_class_ops_class_find_method ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_method_test.ets ) -ani_add_gtest(ani_test_class_ops_find_setter_getter - CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_setter_getter_test.cpp - ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_setter_getter_test.ets -) - -ani_add_gtest(ani_test_class_ops_find_indexable_getter_setter - CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_indexable_getter_setter_test.cpp - ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/class_find_indexable_getter_setter_test.ets -) - ani_add_gtest(ani_test_class_ops_call_static_method_bool CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/call_static_method_bool_test.cpp ETS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/call_static_method_bool_test.ets diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.cpp b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.cpp deleted file mode 100644 index f5d9b6eecc..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License" - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ani/ani.h" -#include "ani_gtest.h" - -namespace ark::ets::ani::testing { - -class FindIndexableGetterTest : public AniTest {}; -class FindIndexableSetterTest : public AniTest {}; -class FindIndexableSetterGetterTest : public AniTest {}; - -TEST_F(FindIndexableGetterTest, get_method) -{ - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_indexable_getter_setter_test/A;", &cls), ANI_OK); - ASSERT_NE(cls, nullptr); - - ani_method method; - ASSERT_EQ(env_->Class_FindIndexableGetter(cls, "D:Lclass_find_indexable_getter_setter_test/A;", &method), ANI_OK); - ASSERT_NE(method, nullptr); - - ASSERT_EQ(env_->Class_FindIndexableGetter(cls, "D:I", &method), ANI_NOT_FOUND); -} - -TEST_F(FindIndexableSetterTest, set_method) -{ - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_indexable_getter_setter_test/A;", &cls), ANI_OK); - ASSERT_NE(cls, nullptr); - - ani_method stringSetter; - ASSERT_EQ(env_->Class_FindIndexableSetter(cls, "DLstd/core/String;:V", &stringSetter), ANI_OK); - ASSERT_NE(stringSetter, nullptr); - - ani_method booleanSetter; - ASSERT_EQ(env_->Class_FindIndexableSetter(cls, "DZ:V", &booleanSetter), ANI_OK); - ASSERT_NE(booleanSetter, nullptr); - ASSERT_NE(booleanSetter, stringSetter); - - ani_method intSetter; - ASSERT_EQ(env_->Class_FindIndexableSetter(cls, "II:V", &intSetter), ANI_NOT_FOUND); -} - -TEST_F(FindIndexableSetterGetterTest, invalid_args) -{ - ani_method method; - ASSERT_EQ(env_->Class_FindIndexableSetter(nullptr, "II:V", &method), ANI_INVALID_ARGS); - ASSERT_EQ(env_->Class_FindIndexableGetter(nullptr, "II:V", &method), ANI_INVALID_ARGS); -} - -TEST_F(FindIndexableGetterTest, check_initialization) -{ - ani_class cls {}; - ASSERT_EQ(env_->FindClass("class_find_indexable_getter_setter_test.A", &cls), ANI_OK); - - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_indexable_getter_setter_test.A")); - ani_method method {}; - ASSERT_EQ(env_->Class_FindIndexableGetter(cls, "D:Lclass_find_indexable_getter_setter_test/A;", &method), ANI_OK); - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_indexable_getter_setter_test.A")); -} - -TEST_F(FindIndexableSetterTest, check_initialization) -{ - ani_class cls {}; - ASSERT_EQ(env_->FindClass("class_find_indexable_getter_setter_test.A", &cls), ANI_OK); - - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_indexable_getter_setter_test.A")); - ani_method method {}; - ASSERT_EQ(env_->Class_FindIndexableSetter(cls, "DZ:V", &method), ANI_OK); - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_indexable_getter_setter_test.A")); -} - -} // namespace ark::ets::ani::testing diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.ets deleted file mode 100644 index f7f47aeccb..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_indexable_getter_setter_test.ets +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class A { - $_get(index: number): A { - return this - } - - $_set(index: number, value: string) {} - - $_set(index: number, value: boolean) {} -} diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.cpp b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.cpp deleted file mode 100644 index 109b67f604..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ani_gtest.h" - -namespace ark::ets::ani::testing { - -class ClassFindIteratorTest : public AniTest { -public: - void GetTestData(ani_class *clsResult, ani_method *ctorResult) - { - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_iterator_test/Singleton;", &cls), ANI_OK); - - ani_method ctor; - ASSERT_EQ(env_->Class_FindMethod(cls, "", ":V", &ctor), ANI_OK); - - *clsResult = cls; - *ctorResult = ctor; - } -}; - -TEST_F(ClassFindIteratorTest, find_iterator) -{ - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_iterator_test/Singleton;", &cls), ANI_OK); - - ani_method result; - ASSERT_EQ(env_->Class_FindIterator(cls, &result), ANI_OK); - - ASSERT_NE(result, nullptr); -} - -TEST_F(ClassFindIteratorTest, find_iterator_in_namespace) -{ - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_iterator_test/ops/Singleton;", &cls), ANI_OK); - - ani_method result; - ASSERT_EQ(env_->Class_FindIterator(cls, &result), ANI_OK); - - ASSERT_NE(result, nullptr); -} - -TEST_F(ClassFindIteratorTest, invalid_argument1) -{ - ani_class cls; - ASSERT_EQ(env_->FindClass("Lclass_find_iterator_test/ops/Singleton;", &cls), ANI_OK); - ani_method result; - ASSERT_EQ(env_->Class_FindIterator(nullptr, &result), ANI_INVALID_ARGS); - ASSERT_EQ(env_->Class_FindIterator(cls, nullptr), ANI_INVALID_ARGS); -} - -TEST_F(ClassFindIteratorTest, check_initialization) -{ - ani_class cls {}; - ASSERT_EQ(env_->FindClass("class_find_iterator_test.ops.Singleton", &cls), ANI_OK); - - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_iterator_test.ops.Singleton")); - ani_method method {}; - ASSERT_EQ(env_->Class_FindIterator(cls, &method), ANI_OK); - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_iterator_test.ops.Singleton")); -} - -} // namespace ark::ets::ani::testing \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.ets deleted file mode 100644 index 23cc700584..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_iterator_test.ets +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// test in namespace ops -namespace ops { -class Singleton { - constructor() { - this.weight = 0; - } - weight: int; - data: int[] = [1, 2, 3] - $_iterator() { // Function type is inferred from its body - return new SingletonIterator(this) - } -} - -class SingletonIterator implements Iterator { - index = 0 - base: Singleton - constructor (base: Singleton) { - this.base = base - } - next(): IteratorResult { - return { - done: this.index >= this.base.data.length, - value: this.index >= this.base.data.length ? undefined : this.base.data[this.index++] - } - } -} -}; - -// test out of namespace ops -class Singleton { - constructor() { - this.weight = 1; - } - weight: int; - data: int[] = [2, 4, 6] - $_iterator() { // Function type is inferred from its body - return new SingletonIterator(this) - } -} - -class SingletonIterator implements Iterator { - index = 0 - age = 0 - base: Singleton - constructor (base: Singleton) { - this.base = base - this.age = 1 - } - next(): IteratorResult { - return { - done: this.index >= this.base.data.length, - value: this.index >= this.base.data.length ? undefined : this.base.data[this.index++] - } - } - } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.cpp b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.cpp index cf9faa9ca1..544bfabf48 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.cpp @@ -86,6 +86,42 @@ public: ASSERT_EQ(result, expectedResult); } + template + void CheckClassFindSetter(const char *clsName, std::string_view propertyName) + { + ani_class cls; + ASSERT_EQ(env_->FindClass(clsName, &cls), ANI_OK) << clsName; + ASSERT_NE(cls, nullptr); + std::string propName(""); + propName += propertyName; + ani_method method; + auto status = env_->Class_FindMethod(cls, propName.c_str(), nullptr, &method); + if constexpr (METHOD_IS_PRESENT) { + ASSERT_EQ(status, ANI_OK); + ASSERT_NE(method, nullptr); + } else { + ASSERT_EQ(status, ANI_NOT_FOUND); + } + } + + template + void CheckClassFindGetter(const char *clsName, const char *propertyName) + { + ani_class cls; + ASSERT_EQ(env_->FindClass(clsName, &cls), ANI_OK) << clsName; + ASSERT_NE(cls, nullptr); + std::string propName(""); + propName += propertyName; + ani_method method; + auto status = env_->Class_FindMethod(cls, propName.c_str(), nullptr, &method); + if constexpr (METHOD_IS_PRESENT) { + ASSERT_EQ(status, ANI_OK); + ASSERT_NE(method, nullptr); + } else { + ASSERT_EQ(status, ANI_NOT_FOUND); + } + } + void CheckIntrinsicsFindMethod(const char *moduleDescriptor, const char *clsDescriptor, const char *methodName, const char *methodSignature) { @@ -297,7 +333,7 @@ TEST_F(ClassFindMethodTest, special_types1) ani_object mapValue; RecordCreator(&cls, &mapValue); ani_method setter; - ASSERT_EQ(env_->Class_FindIndexableSetter(cls, nullptr, &setter), ANI_OK); + ASSERT_EQ(env_->Class_FindMethod(cls, "$_set", nullptr, &setter), ANI_OK); ani_string string {}; ASSERT_EQ(env_->String_NewUTF8(ARG_STRING.data(), ARG_STRING.size(), &string), ANI_OK); @@ -1129,6 +1165,80 @@ TEST_F(ClassFindMethodTest, static_no_duplicate) ASSERT_EQ(env_->Class_FindMethod(baseCls, "notOverloaded", nullptr, &method), ANI_OK); } +TEST_F(ClassFindMethodTest, has_set_methods) +{ + CheckClassFindSetter("test.ExplicitMethods", "age"); + CheckClassFindSetter("test.StyledRectangle", "color"); + CheckClassFindSetter("test.OnlySet", "field"); +} + +TEST_F(ClassFindMethodTest, has_get_method) +{ + CheckClassFindGetter("test.ExplicitMethods", "age"); + CheckClassFindGetter("test.StyledRectangle", "color"); + CheckClassFindGetter("test.OnlyGet", "field"); +} + +TEST_F(ClassFindMethodTest, no_set_method) +{ + CheckClassFindSetter("test.ImplicitMethods", "field"); + CheckClassFindSetter("test.OnlyGet", "field"); +} + +TEST_F(ClassFindMethodTest, indexable_getter) +{ + ani_class cls; + ASSERT_EQ(env_->FindClass("test.IndexableClass", &cls), ANI_OK); + ASSERT_NE(cls, nullptr); + + ani_method method; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_get", "d:C{test.IndexableClass}", &method), ANI_OK); + ASSERT_NE(method, nullptr); + + ASSERT_EQ(env_->Class_FindMethod(cls, "$_get", "d:i", &method), ANI_NOT_FOUND); +} + +TEST_F(ClassFindMethodTest, indexable_setter) +{ + ani_class cls; + ASSERT_EQ(env_->FindClass("test.IndexableClass", &cls), ANI_OK); + ASSERT_NE(cls, nullptr); + + ani_method stringSetter; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_set", "dC{std.core.String}:", &stringSetter), ANI_OK); + ASSERT_NE(stringSetter, nullptr); + + ani_method booleanSetter; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_set", "dz:", &booleanSetter), ANI_OK); + ASSERT_NE(booleanSetter, nullptr); + ASSERT_NE(booleanSetter, stringSetter); + + ani_method intSetter; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_set", "ii:", &intSetter), ANI_NOT_FOUND); +} + +TEST_F(ClassFindMethodTest, find_iterator) +{ + ani_class cls; + ASSERT_EQ(env_->FindClass("test.Singleton", &cls), ANI_OK); + + ani_method result; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_iterator", nullptr, &result), ANI_OK); + + ASSERT_NE(result, nullptr); +} + +TEST_F(ClassFindMethodTest, find_iterator_in_namespace) +{ + ani_class cls; + ASSERT_EQ(env_->FindClass("test.ops.Singleton", &cls), ANI_OK); + + ani_method result; + ASSERT_EQ(env_->Class_FindMethod(cls, "$_iterator", nullptr, &result), ANI_OK); + + ASSERT_NE(result, nullptr); +} + TEST_F(ClassFindMethodTest, check_initalization) { ani_class cls {}; diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets index c4c25817e1..d8cae7499f 100644 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets +++ b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_method_test.ets @@ -136,7 +136,7 @@ class C implements I { abstract class Base { public abstract abstract_method(x: int): int - + public method(x: int) { return 2 * x; @@ -146,7 +146,7 @@ abstract class Base { class Derived extends Base { constructor() { } - + public override abstract_method(x: int): int { return x; @@ -156,12 +156,12 @@ class Derived extends Base { class Overload { constructor() { } - + private method(x: int): int { return x; } - + private method(x: int, y: boolean): int { return 2 * x; @@ -476,7 +476,7 @@ interface ICalculator { add(x: int, y: int): int; subtract(x: int, y: int): int; } - + class BasicCalculator implements ICalculator { add(x: int, y: int): int { return x + y; @@ -545,3 +545,105 @@ class NotOverloaded { class FindNativeMethods { native foo(): int; } + + +interface Style { + color : string +} + +class StyledRectangle implements Style { + color: string = "" +} + +class ExplicitMethods { + private age_: number = 0 + set age(x: number) { + } + get age(): number { + return this.age_ + } +} + +class ImplicitMethods { + field: number +} + +class OnlyGet { + public field_: boolean = true + get field(): boolean { + return this.field_ + } +} + +class OnlySet { + public field_: boolean = true + set field(x: number) { + } +} + + +class IndexableClass { + $_get(index: number): IndexableClass { + return this + } + + $_set(index: number, value: string) {} + + $_set(index: number, value: boolean) {} +} + +// test in namespace ops +namespace ops { +class Singleton { + constructor() { + this.weight = 0; + } + weight: int; + data: int[] = [1, 2, 3] + $_iterator() { // Function type is inferred from its body + return new SingletonIterator(this) + } +} + +class SingletonIterator implements Iterator { + index = 0 + base: Singleton + constructor (base: Singleton) { + this.base = base + } + next(): IteratorResult { + return { + done: this.index >= this.base.data.length, + value: this.index >= this.base.data.length ? undefined : this.base.data[this.index++] + } + } +} +}; + +// test out of namespace ops +class Singleton { + constructor() { + this.weight = 1; + } + weight: int; + data: int[] = [2, 4, 6] + $_iterator() { // Function type is inferred from its body + return new SingletonIterator(this) + } +} + +class SingletonIterator implements Iterator { + index = 0 + age = 0 + base: Singleton + constructor (base: Singleton) { + this.base = base + this.age = 1 + } + next(): IteratorResult { + return { + done: this.index >= this.base.data.length, + value: this.index >= this.base.data.length ? undefined : this.base.data[this.index++] + } + } +} diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.cpp b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.cpp deleted file mode 100644 index 422cccc29c..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License" - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ani/ani.h" -#include "ani_gtest.h" - -namespace ark::ets::ani::testing { - -class FindSetterTest : public AniTest { -public: - template - void CheckClassFindSetter(const char *clsName, const char *propertyName) - { - ani_class cls; - ASSERT_EQ(env_->FindClass(clsName, &cls), ANI_OK); - ASSERT_NE(cls, nullptr); - ani_method method; - auto status = env_->Class_FindSetter(cls, propertyName, &method); - if constexpr (METHOD_IS_PRESENT) { - ASSERT_EQ(status, ANI_OK); - ASSERT_NE(method, nullptr); - } else { - ASSERT_EQ(status, ANI_NOT_FOUND); - } - } -}; - -class FindGetterTest : public AniTest { -public: - template - void CheckClassFindGetter(const char *clsName, const char *propertyName) - { - ani_class cls; - ASSERT_EQ(env_->FindClass(clsName, &cls), ANI_OK); - ASSERT_NE(cls, nullptr); - ani_method method; - auto status = env_->Class_FindGetter(cls, propertyName, &method); - if constexpr (METHOD_IS_PRESENT) { - ASSERT_EQ(status, ANI_OK); - ASSERT_NE(method, nullptr); - } else { - ASSERT_EQ(status, ANI_NOT_FOUND); - } - } -}; - -class FindGetterSetterTest : public AniTest {}; - -TEST_F(FindSetterTest, has_set_methods) -{ - CheckClassFindSetter("Lclass_find_setter_getter_test/ExplicitMethods;", "age"); - CheckClassFindSetter("Lclass_find_setter_getter_test/StyledRectangle;", "color"); - CheckClassFindSetter("Lclass_find_setter_getter_test/OnlySet;", "field"); -} - -TEST_F(FindGetterTest, has_get_method) -{ - CheckClassFindGetter("Lclass_find_setter_getter_test/ExplicitMethods;", "age"); - CheckClassFindGetter("Lclass_find_setter_getter_test/StyledRectangle;", "color"); - CheckClassFindGetter("Lclass_find_setter_getter_test/OnlyGet;", "field"); -} - -TEST_F(FindSetterTest, no_set_method) -{ - CheckClassFindSetter("Lclass_find_setter_getter_test/ImplicitMethods;", "field"); - CheckClassFindSetter("Lclass_find_setter_getter_test/OnlyGet;", "field"); -} - -TEST_F(FindGetterTest, no_get_method) -{ - CheckClassFindGetter("Lclass_find_setter_getter_test/ImplicitMethods;", "field"); - CheckClassFindGetter("Lclass_find_setter_getter_test/OnlySet;", "field"); -} - -TEST_F(FindGetterSetterTest, invalid_args) -{ - ani_method method; - ASSERT_EQ(env_->Class_FindSetter(nullptr, "field", &method), ANI_INVALID_ARGS); - ASSERT_EQ(env_->Class_FindGetter(nullptr, "field", &method), ANI_INVALID_ARGS); -} - -TEST_F(FindSetterTest, check_initialization) -{ - ani_class cls {}; - ASSERT_EQ(env_->FindClass("class_find_setter_getter_test.ExplicitMethods", &cls), ANI_OK); - - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_setter_getter_test.ExplicitMethods")); - ani_method method {}; - ASSERT_EQ(env_->Class_FindSetter(cls, "age", &method), ANI_OK); - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_setter_getter_test.ExplicitMethods")); -} - -TEST_F(FindGetterTest, check_initialization) -{ - ani_class cls {}; - ASSERT_EQ(env_->FindClass("class_find_setter_getter_test.ExplicitMethods", &cls), ANI_OK); - - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_setter_getter_test.ExplicitMethods")); - ani_method method {}; - ASSERT_EQ(env_->Class_FindGetter(cls, "age", &method), ANI_OK); - ASSERT_FALSE(IsRuntimeClassInitialized("class_find_setter_getter_test.ExplicitMethods")); -} - -} // namespace ark::ets::ani::testing diff --git a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.ets b/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.ets deleted file mode 100644 index 3cf20e5e87..0000000000 --- a/static_core/plugins/ets/tests/ani/tests/class_ops/class_find_setter_getter_test.ets +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -interface Style { - color : string -} - -class StyledRectangle implements Style { - color: string = "" -} - -class ExplicitMethods { - private age_: number = 0 - set age(x: number) { - } - get age(): number { - return this.age_ - } -} - -class ImplicitMethods { - field: number -} - -class OnlyGet { - public field_: boolean = true - get field(): boolean { - return this.field_ - } -} - -class OnlySet { - public field_: boolean = true - set field(x: number) { - } -} diff --git a/static_core/plugins/ets/tests/ani/tests/error_ops/error_handling_test.cpp b/static_core/plugins/ets/tests/ani/tests/error_ops/error_handling_test.cpp index f0c0297926..dbcf18c5cb 100644 --- a/static_core/plugins/ets/tests/ani/tests/error_ops/error_handling_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/error_ops/error_handling_test.cpp @@ -626,7 +626,7 @@ static std::string GetErrorProperty(ani_env *aniEnv, ani_error aniError, const c return propertyValue; } ani_method getterMethod = nullptr; - if ((aniEnv->Class_FindGetter(static_cast(errorType), property, &getterMethod)) != ANI_OK) { + if ((aniEnv->Class_FindMethod(static_cast(errorType), property, nullptr, &getterMethod)) != ANI_OK) { return propertyValue; } ani_ref aniRef = nullptr; @@ -657,7 +657,7 @@ TEST_F(ErrorHandlingTest, call_error_stack) ASSERT_EQ(env_->GetUnhandledError(&error), ANI_OK); ASSERT_EQ(env_->ResetError(), ANI_OK); - std::string stack = GetErrorProperty(env_, error, "stack"); + std::string stack = GetErrorProperty(env_, error, "stack"); std::stringstream ss(stack); std::regex pattern(R"(\s*at .*(\d+):(\d+)\))"); std::string token; diff --git a/static_core/plugins/ets/tests/ani/tests/mangling/mangle_signature_test.cpp b/static_core/plugins/ets/tests/ani/tests/mangling/mangle_signature_test.cpp index c1bed415bd..72af668bdc 100644 --- a/static_core/plugins/ets/tests/ani/tests/mangling/mangle_signature_test.cpp +++ b/static_core/plugins/ets/tests/ani/tests/mangling/mangle_signature_test.cpp @@ -546,7 +546,7 @@ TEST_F(MangleSignatureTest, Class_FindIndexableGetter) ASSERT_EQ(env_->FindClass("msig.F", &cls), ANI_OK); ani_method method {}; - EXPECT_EQ(env_->Class_FindIndexableGetter(cls, "d:i", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_get", "d:i", &method), ANI_OK); } TEST_F(MangleSignatureTest, Class_FindIndexableGetter_OldFormat) @@ -557,7 +557,7 @@ TEST_F(MangleSignatureTest, Class_FindIndexableGetter_OldFormat) ASSERT_EQ(env_->FindClass("Lmsig/F;", &cls), ANI_OK); ani_method method {}; - EXPECT_EQ(env_->Class_FindIndexableGetter(cls, "D:I", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_get", "D:I", &method), ANI_OK); } TEST_F(MangleSignatureTest, Class_FindIndexableSetter) @@ -569,16 +569,16 @@ TEST_F(MangleSignatureTest, Class_FindIndexableSetter) ani_method method {}; // Check primitives - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "dz:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "dc:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "ds:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "di:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "dl:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "df:", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "dd:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "dz:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "dc:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "ds:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "di:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "dl:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "df:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "dd:", &method), ANI_OK); // Check references - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "dC{std.core.String}:", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "dC{std.core.String}:", &method), ANI_OK); } TEST_F(MangleSignatureTest, Class_FindIndexableSetter_OldFormat) @@ -591,16 +591,16 @@ TEST_F(MangleSignatureTest, Class_FindIndexableSetter_OldFormat) ani_method method {}; // Check primitives - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DZ:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DC:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DS:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DI:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DJ:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DF:V", &method), ANI_OK); - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DD:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DZ:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DC:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DS:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DI:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DJ:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DF:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DD:V", &method), ANI_OK); // Check references - EXPECT_EQ(env_->Class_FindIndexableSetter(cls, "DLstd/core/String;:V", &method), ANI_OK); + EXPECT_EQ(env_->Class_FindMethod(cls, "$_set", "DLstd/core/String;:V", &method), ANI_OK); } TEST_F(MangleSignatureTest, Class_CallStaticMethodByName) -- Gitee