From a5b09a67034e57a6e10231dd4bd92f4cb50b824c Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 17 Nov 2016 15:21:22 -0800 Subject: ART: Add dex::TypeIndex Add abstraction for uint16_t type index. Test: m test-art-host Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a --- runtime/dex_file_annotations.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'runtime/dex_file_annotations.cc') diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc index 835f456c9b..3fe2c409ca 100644 --- a/runtime/dex_file_annotations.cc +++ b/runtime/dex_file_annotations.cc @@ -90,7 +90,7 @@ const DexFile::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(type_index)) == 0) { + if (strcmp(descriptor, dex_file.StringByTypeIdx(dex::TypeIndex(type_index))) == 0) { result = annotation_item; break; } @@ -246,7 +246,7 @@ mirror::Object* ProcessEncodedAnnotation(Handle klass, const uint StackHandleScope<2> hs(self); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); Handle annotation_class(hs.NewHandle( - class_linker->ResolveType(klass->GetDexFile(), type_index, klass.Get()))); + class_linker->ResolveType(klass->GetDexFile(), dex::TypeIndex(type_index), klass.Get()))); if (annotation_class.Get() == nullptr) { LOG(INFO) << "Unable to resolve " << klass->PrettyClass() << " annotation class " << type_index; DCHECK(Thread::Current()->IsExceptionPending()); @@ -370,13 +370,14 @@ bool ProcessAnnotationValue(Handle klass, if (result_style == DexFile::kAllRaw) { annotation_value->value_.SetI(index); } else { + dex::TypeIndex type_index(index); element_object = Runtime::Current()->GetClassLinker()->ResolveType( - klass->GetDexFile(), index, klass.Get()); + klass->GetDexFile(), type_index, klass.Get()); set_object = true; if (element_object == nullptr) { CHECK(self->IsExceptionPending()); if (result_style == DexFile::kAllObjects) { - const char* msg = dex_file.StringByTypeIdx(index); + const char* msg = dex_file.StringByTypeIdx(type_index); self->ThrowNewWrappedException("Ljava/lang/TypeNotPresentException;", msg); element_object = self->GetException(); self->ClearException(); @@ -665,7 +666,7 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( const uint8_t* annotation = annotation_item->annotation_; uint32_t type_index = DecodeUnsignedLeb128(&annotation); mirror::Class* resolved_class = Runtime::Current()->GetClassLinker()->ResolveType( - klass->GetDexFile(), type_index, klass.Get()); + klass->GetDexFile(), dex::TypeIndex(type_index), klass.Get()); if (resolved_class == nullptr) { std::string temp; LOG(WARNING) << StringPrintf("Unable to resolve %s annotation class %d", @@ -1345,7 +1346,9 @@ void RuntimeEncodedStaticFieldValueIterator::ReadValueToField(ArtField* field) c break; } case kType: { - mirror::Class* resolved = linker_->ResolveType(dex_file_, jval_.i, *dex_cache_, + mirror::Class* resolved = linker_->ResolveType(dex_file_, + dex::TypeIndex(jval_.i), + *dex_cache_, *class_loader_); field->SetObject(field->GetDeclaringClass(), resolved); break; -- cgit v1.2.3-59-g8ed1b