summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2024-11-29 16:19:34 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2024-12-02 14:39:04 +0000
commitdd303e6a584f9fb09813ec4b643261c2b33b0b53 (patch)
treef155dd501440e894739f493eba4c179ff69a54bc /runtime/class_linker.cc
parent4e56223e8643b7686b12e4e6dc933d122ed29920 (diff)
Only constructor names can start with `<`.
`DexFileVerifier::CheckClassDataItemMethod()` rejects method names starting with '<' other than "<init>" and "<clinit>". 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
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc17
1 files changed, 7 insertions, 10 deletions
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("<init>", sizeof("<init>") - 1u);
- bool is_clinit = has_ascii_name("<clinit>", sizeof("<clinit>") - 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("<init>", sizeof("<init>") - 1u) ||
+ has_ascii_name("<clinit>", sizeof("<clinit>") - 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;
}
}