Revert "Move runtime/ to ClassAccessor"
Seems to cause 'atest CtsInlineMockingTestCases' and other tests
to fail due to sending agents dex files with hiddenapi flags still
present.
This reverts commit 2649ecf6c59a29262556aa356fbf894d49df8fe7.
Reason for revert: Seems to be causing sysui test failures, maybe
Bug: 77709234
Bug: 79758018
Bug: 91962648
Test: Tree-Hugger
Change-Id: I2cab5d0d58808dd8beb38400d2811307f26e1021
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 4e9f3c5..151c36f 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -26,7 +26,6 @@
#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"
@@ -435,14 +434,28 @@
static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file,
uint16_t class_def_idx,
uint32_t 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) {
+ 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) {
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();
}