From dd303e6a584f9fb09813ec4b643261c2b33b0b53 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 29 Nov 2024 16:19:34 +0000 Subject: Only constructor names can start with `<`. `DexFileVerifier::CheckClassDataItemMethod()` rejects method names starting with '<' other than "" and "". Therefore `ClassLinker::LoadMethod()` does not need to check the whole method name when checking for constructors without the `kAccConstructor` flag. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I41dbedc1b6dd2e26444a2198a82ab65b6ab4a43e --- runtime/class_linker.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 0c9b6e2f55..c2926ac263 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -4165,16 +4165,13 @@ void ClassLinker::LoadMethod(const DexFile& dex_file, } } else if (method_name[0] == '<') { // Fix broken access flags for initializers. Bug 11157540. - bool is_init = has_ascii_name("", sizeof("") - 1u); - bool is_clinit = has_ascii_name("", sizeof("") - 1u); - if (UNLIKELY(!is_init && !is_clinit)) { - LOG(WARNING) << "Unexpected '<' at start of method name " << method_name; - } else { - if (UNLIKELY((access_flags & kAccConstructor) == 0)) { - LOG(WARNING) << method_name << " didn't have expected constructor access flag in class " - << klass->PrettyDescriptor() << " in dex file " << dex_file.GetLocation(); - access_flags |= kAccConstructor; - } + // `DexFileVerifier` rejects method names starting with '<' other than constructors. + DCHECK(has_ascii_name("", sizeof("") - 1u) || + has_ascii_name("", sizeof("") - 1u)) << method_name; + if (UNLIKELY((access_flags & kAccConstructor) == 0)) { + LOG(WARNING) << method_name << " didn't have expected constructor access flag in class " + << klass->PrettyDescriptor() << " in dex file " << dex_file.GetLocation(); + access_flags |= kAccConstructor; } } -- cgit v1.2.3-59-g8ed1b