diff options
author | 2024-04-09 12:49:48 +0000 | |
---|---|---|
committer | 2024-04-11 15:10:07 +0000 | |
commit | e8da7cd1d0e7d3535c82f8d05adcef3edd43cd40 (patch) | |
tree | f39114f368998a7b6415bb905fa71dc04dc3b232 /runtime/dex/dex_file_annotations.cc | |
parent | 69dc24557f951ce2513d0ea77f35a499fa58467b (diff) |
Clean up string data access in `DexFile`.
The `*ByIdx()` and `*ByTypeIdx()` functions were doing
validity checks that were needed only for processing the
debug data, so move the checks to these callers. Replace
these functions with new overloads of other functions to
provide consistent naming.
In a few cases, rewrite calls to these functions to fetch
and work with a `string_view` instead.
Rename `GetStringLength()` to `GetStringUtf16Length()` and
change its return type to `uint32_t`.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I561899606f6e5ec5f23aa4be617349dacdb376e3
Diffstat (limited to 'runtime/dex/dex_file_annotations.cc')
-rw-r--r-- | runtime/dex/dex_file_annotations.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc index 8488993ae4..3d334e70fd 100644 --- a/runtime/dex/dex_file_annotations.cc +++ b/runtime/dex/dex_file_annotations.cc @@ -193,7 +193,7 @@ const AnnotationItem* SearchAnnotationSet(const DexFile& dex_file, const uint8_t* annotation = annotation_item->annotation_; uint32_t type_index = DecodeUnsignedLeb128(&annotation); - if (strcmp(descriptor, dex_file.StringByTypeIdx(dex::TypeIndex(type_index))) == 0) { + if (strcmp(descriptor, dex_file.GetTypeDescriptor(dex::TypeIndex(type_index))) == 0) { result = annotation_item; break; } @@ -495,7 +495,7 @@ bool ProcessAnnotationValue(const ClassData& klass, if (element_object == nullptr) { CHECK(self->IsExceptionPending()); if (result_style == DexFile::kAllObjects) { - const char* msg = dex_file.StringByTypeIdx(type_index); + const char* msg = dex_file.GetTypeDescriptor(type_index); self->ThrowNewWrappedException("Ljava/lang/TypeNotPresentException;", msg); element_object = self->GetException(); self->ClearException(); @@ -701,7 +701,7 @@ ObjPtr<mirror::Object> CreateAnnotationMember(const ClassData& klass, ScopedObjectAccessUnchecked soa(self); StackHandleScope<5> hs(self); uint32_t element_name_index = DecodeUnsignedLeb128(annotation); - const char* name = dex_file.StringDataByIdx(dex::StringIndex(element_name_index)); + const char* name = dex_file.GetStringData(dex::StringIndex(element_name_index)); PointerSize pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize(); ArtMethod* annotation_method = @@ -1286,7 +1286,7 @@ static bool IsMethodBuildAnnotationPresent(const DexFile& dex_file, } const uint8_t* annotation = annotation_item->annotation_; uint32_t type_index = DecodeUnsignedLeb128(&annotation); - const char* descriptor = dex_file.StringByTypeIdx(dex::TypeIndex(type_index)); + const char* descriptor = dex_file.GetTypeDescriptor(dex::TypeIndex(type_index)); if (strcmp(descriptor, annotation_descriptor) == 0) { DCheckNativeAnnotation(descriptor, annotation_class); return true; @@ -1754,7 +1754,7 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) { return nullptr; } dex::StringIndex index(static_cast<uint32_t>(annotation_value.value_.GetI())); - return data.GetDexFile().StringDataByIdx(index); + return data.GetDexFile().GetStringData(index); } ObjPtr<mirror::Class> GetNestHost(Handle<mirror::Class> klass) { @@ -1994,7 +1994,7 @@ void VisitClassAnnotations(Handle<mirror::Class> klass, AnnotationVisitor* visit uint8_t visibility = annotation_item->visibility_; const uint8_t* annotation = annotation_item->annotation_; uint32_t type_index = DecodeUnsignedLeb128(&annotation); - const char* annotation_descriptor = dex_file.StringByTypeIdx(dex::TypeIndex(type_index)); + const char* annotation_descriptor = dex_file.GetTypeDescriptor(dex::TypeIndex(type_index)); VisitorStatus status = visitor->VisitAnnotation(annotation_descriptor, visibility); switch (status) { case VisitorStatus::kVisitBreak: |