Revert "Revert "Move runtime/ to ClassAccessor""
Fixed misplaced UnhideAccessFlags to be outside of a conditional
that the code item is null / not deduped. This fixes an issue
where these methods would not have had their access flags restored.
Bug: 77709234
Bug: 79758018
Bug: 91962648
This reverts commit cc7e20f9ec7b4a7a57f7196e5e8be67a727f21d3.
Test: test-art-host
Test: atest FrameworksUiServicesTests
Test: atest CtsInlineMockingTestCases
Change-Id: I7e5712cdcccef81e19ce81d26743c517b0b8a67d
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 151c36f..4e9f3c5 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -26,6 +26,7 @@
#include "class_linker-inl.h"
#include "class_root.h"
#include "debugger.h"
+#include "dex/class_accessor-inl.h"
#include "dex/descriptors_names.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file_exception_helpers.h"
@@ -434,28 +435,14 @@
static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file,
uint16_t class_def_idx,
uint32_t method_idx) {
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
- const uint8_t* class_data = dex_file.GetClassData(class_def);
- CHECK(class_data != nullptr);
- ClassDataItemIterator it(dex_file, class_data);
- it.SkipAllFields();
- // Process methods
- size_t class_def_method_index = 0;
- while (it.HasNextDirectMethod()) {
- if (it.GetMemberIndex() == method_idx) {
+ ClassAccessor accessor(dex_file, dex_file.GetClassDef(class_def_idx));
+ uint32_t class_def_method_index = 0u;
+ for (const ClassAccessor::Method& method : accessor.GetMethods()) {
+ if (method.GetIndex() == method_idx) {
return class_def_method_index;
}
class_def_method_index++;
- it.Next();
}
- while (it.HasNextVirtualMethod()) {
- if (it.GetMemberIndex() == method_idx) {
- return class_def_method_index;
- }
- class_def_method_index++;
- it.Next();
- }
- DCHECK(!it.HasNext());
LOG(FATAL) << "Failed to find method index " << method_idx << " in " << dex_file.GetLocation();
UNREACHABLE();
}