summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2024-06-14 11:58:13 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2025-02-07 07:06:46 -0800
commitf850690a901c01d95210e3ecf66aa7255206aafc (patch)
tree98e871f5de2416109316eb25076380ed80638beb
parent08f1b58976bae5514a0d6877b4e8f68ff15bcafb (diff)
Use `ClassAccessor::GetViewDescriptor()` more.
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 338123769 Change-Id: Ib8206f037ece05374e16b8a3816520ea9bc70931
-rw-r--r--dex2oat/dex2oat_test.cc2
-rw-r--r--dex2oat/driver/compiler_driver.cc5
-rw-r--r--libdexfile/dex/class_accessor_test.cc3
-rw-r--r--tools/hiddenapi/hiddenapi.cc18
-rw-r--r--tools/hiddenapi/hiddenapi_test.cc10
-rw-r--r--tools/veridex/precise_hidden_api_finder.cc2
-rw-r--r--tools/veridex/resolver.cc2
7 files changed, 22 insertions, 20 deletions
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 7013bbce0c..9d837cbf67 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1797,7 +1797,7 @@ TEST_F(Dex2oatTest, AppImageResolveStrings) {
bool mutated_successfully = false;
// Change the dex instructions to make an opcode that spans past the end of the code item.
for (ClassAccessor accessor : dex->GetClasses()) {
- if (accessor.GetDescriptor() == std::string("LStringLiterals$StartupClass;")) {
+ if (accessor.GetDescriptorView() == "LStringLiterals$StartupClass;") {
classes.push_back(accessor.GetClassIdx());
}
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index fc2d94a342..ddf9bbda84 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -1813,7 +1813,8 @@ static void LoadAndUpdateStatus(const ClassAccessor& accessor,
// a boot image class, or a class in a different dex file for multidex, and
// we should not update the status in that case.
if (&cls->GetDexFile() == &accessor.GetDexFile()) {
- VLOG(compiler) << "Updating class status of " << accessor.GetDescriptor() << " to " << status;
+ VLOG(compiler) << "Updating class status of " << accessor.GetDescriptorView()
+ << " to " << status;
ObjectLock<mirror::Class> lock(self, cls);
mirror::Class::SetStatus(cls, status, self);
}
@@ -1880,7 +1881,7 @@ bool CompilerDriver::FastVerify(jobject jclass_loader,
// If the class will be in the image, we can rely on the ArtMethods
// telling that they need access checks.
VLOG(compiler) << "Promoting "
- << std::string(accessor.GetDescriptor())
+ << accessor.GetDescriptorView()
<< " from needs access checks to verified given it is an image class";
status = ClassStatus::kVerified;
}
diff --git a/libdexfile/dex/class_accessor_test.cc b/libdexfile/dex/class_accessor_test.cc
index cb50096084..5c83ea5df6 100644
--- a/libdexfile/dex/class_accessor_test.cc
+++ b/libdexfile/dex/class_accessor_test.cc
@@ -31,7 +31,8 @@ TEST_F(ClassAccessorTest, TestVisiting) {
ASSERT_GT(dex_file->NumClassDefs(), 0u);
for (ClassAccessor accessor : dex_file->GetClasses()) {
const dex::ClassDef& class_def = dex_file->GetClassDef(accessor.GetClassDefIndex());
- EXPECT_EQ(accessor.GetDescriptor(), dex_file->GetTypeDescriptor(class_def.class_idx_));
+ EXPECT_EQ(accessor.GetDescriptorView(),
+ dex_file->GetTypeDescriptorView(class_def.class_idx_));
EXPECT_EQ(class_def_idx, accessor.GetClassDefIndex());
++class_def_idx;
// Check iterators against visitors.
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index bc73865019..f5a8d58374 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -148,11 +148,11 @@ class DexClass : public ClassAccessor {
inline bool IsInterface() const { return HasAccessFlags(kAccInterface); }
inline bool Equals(const DexClass& other) const {
- bool equals = strcmp(GetDescriptor(), other.GetDescriptor()) == 0;
+ bool equals = GetDescriptorView() == other.GetDescriptorView();
if (equals) {
- LOG(FATAL) << "Class duplication: " << GetDescriptor() << " in " << dex_file_.GetLocation()
- << " and " << other.dex_file_.GetLocation();
+ LOG(FATAL) << "Class duplication: " << GetDescriptorView() << " in "
+ << dex_file_.GetLocation() << " and " << other.dex_file_.GetLocation();
}
return equals;
@@ -192,7 +192,7 @@ class DexMember {
// Constructs a string with a unique signature of this class member.
std::string GetApiEntry() const {
std::stringstream ss;
- ss << klass_.GetDescriptor() << "->" << GetName() << (IsMethod() ? "" : ":")
+ ss << klass_.GetDescriptorView() << "->" << GetName() << (IsMethod() ? "" : ":")
<< GetSignature();
return ss.str();
}
@@ -450,7 +450,7 @@ class Hierarchy final {
// Returns true if at least one resolvable member was found.
template<typename Fn>
bool ForEachResolvableMember(const DexMember& other, Fn fn) {
- HierarchyClass* klass = FindClass(other.GetDeclaringClass().GetDescriptor());
+ HierarchyClass* klass = FindClass(other.GetDeclaringClass().GetDescriptorView());
return (klass != nullptr) && klass->ForEachResolvableMember(other, fn);
}
@@ -473,7 +473,7 @@ class Hierarchy final {
// Example code (`foo` exposed by ClassB):
// class ClassA { public void foo() { ... } }
// public class ClassB extends ClassA {}
- HierarchyClass* klass = FindClass(member.GetDeclaringClass().GetDescriptor());
+ HierarchyClass* klass = FindClass(member.GetDeclaringClass().GetDescriptorView());
CHECK(klass != nullptr);
bool visible = false;
klass->ForEachSubClass([&visible, &member](HierarchyClass* subclass) {
@@ -497,7 +497,7 @@ class Hierarchy final {
}
private:
- HierarchyClass* FindClass(const std::string_view& descriptor) {
+ HierarchyClass* FindClass(std::string_view descriptor) {
auto it = classes_.find(descriptor);
if (it == classes_.end()) {
return nullptr;
@@ -510,7 +510,7 @@ class Hierarchy final {
// Create one HierarchyClass entry in `classes_` per class descriptor
// and add all DexClass objects with the same descriptor to that entry.
classpath_.ForEachDexClass([this](const DexClass& klass) {
- classes_[klass.GetDescriptor()].AddDexClass(klass);
+ classes_[klass.GetDescriptorView()].AddDexClass(klass);
});
// Connect each HierarchyClass to its successors and predecessors.
@@ -532,7 +532,7 @@ class Hierarchy final {
auto severity = verbose ? ::android::base::WARNING : ::android::base::FATAL;
LOG(severity)
<< "Superclass/interface " << extends_desc
- << " of class " << dex_klass.GetDescriptor() << " from dex file \""
+ << " of class " << dex_klass.GetDescriptorView() << " from dex file \""
<< dex_klass.GetDexFile().GetLocation() << "\" was not found. "
<< "Either it is missing or it appears later in the classpath spec.";
}
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index fe7677efff..3236dddfd3 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -178,7 +178,7 @@ class HiddenApiTest : public CommonRuntimeTest {
const dex::ClassDef& class_def,
const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
- CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
+ CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptorView() << " has no data";
if (!accessor.HasHiddenapiClassData()) {
return hiddenapi::ApiList::Sdk();
@@ -189,7 +189,7 @@ class HiddenApiTest : public CommonRuntimeTest {
if (strcmp(name, dex_file.GetFieldName(fid)) == 0) {
const uint32_t actual_visibility = field.GetAccessFlags() & kAccVisibilityFlags;
CHECK_EQ(actual_visibility, expected_visibility)
- << "Field " << name << " in class " << accessor.GetDescriptor();
+ << "Field " << name << " in class " << accessor.GetDescriptorView();
return hiddenapi::ApiList(field.GetHiddenapiFlags());
}
}
@@ -205,7 +205,7 @@ class HiddenApiTest : public CommonRuntimeTest {
const dex::ClassDef& class_def,
const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
- CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
+ CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptorView() << " has no data";
if (!accessor.HasHiddenapiClassData()) {
return hiddenapi::ApiList::Sdk();
@@ -215,10 +215,10 @@ class HiddenApiTest : public CommonRuntimeTest {
const dex::MethodId& mid = dex_file.GetMethodId(method.GetIndex());
if (strcmp(name, dex_file.GetMethodName(mid)) == 0) {
CHECK_EQ(expected_native, method.MemberIsNative())
- << "Method " << name << " in class " << accessor.GetDescriptor();
+ << "Method " << name << " in class " << accessor.GetDescriptorView();
const uint32_t actual_visibility = method.GetAccessFlags() & kAccVisibilityFlags;
CHECK_EQ(actual_visibility, expected_visibility)
- << "Method " << name << " in class " << accessor.GetDescriptor();
+ << "Method " << name << " in class " << accessor.GetDescriptorView();
return hiddenapi::ApiList(method.GetHiddenapiFlags());
}
}
diff --git a/tools/veridex/precise_hidden_api_finder.cc b/tools/veridex/precise_hidden_api_finder.cc
index d9eb271bc4..d02a0a2bd8 100644
--- a/tools/veridex/precise_hidden_api_finder.cc
+++ b/tools/veridex/precise_hidden_api_finder.cc
@@ -37,7 +37,7 @@ void PreciseHiddenApiFinder::RunInternal(
const std::function<void(VeridexResolver*, const ClassAccessor::Method&)>& action) {
for (const std::unique_ptr<VeridexResolver>& resolver : resolvers) {
for (ClassAccessor accessor : resolver->GetDexFile().GetClasses()) {
- if (class_filter.Matches(accessor.GetDescriptor())) {
+ if (class_filter.Matches(accessor.GetDescriptorView())) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
if (method.GetCodeItem() != nullptr) {
action(resolver.get(), method);
diff --git a/tools/veridex/resolver.cc b/tools/veridex/resolver.cc
index a56ea6e5ae..211168394e 100644
--- a/tools/veridex/resolver.cc
+++ b/tools/veridex/resolver.cc
@@ -27,7 +27,7 @@ namespace art {
void VeridexResolver::Run() {
for (ClassAccessor accessor : dex_file_.GetClasses()) {
- std::string name(accessor.GetDescriptor());
+ std::string name(accessor.GetDescriptorView());
auto existing = type_map_.find(name);
const uint32_t type_idx = accessor.GetClassIdx().index_;
if (existing != type_map_.end()) {