diff options
author | 2017-07-27 18:02:40 +0000 | |
---|---|---|
committer | 2017-07-27 18:02:40 +0000 | |
commit | f6fe3cb9224f9e87974806ff03fc43f9e1f736cb (patch) | |
tree | a23cff8f1581f828fe405c7d2cdd01c15cdfb643 | |
parent | 67abbca7cf23ef8b5c0aded0cd0a20765ff47cf2 (diff) | |
parent | 370f57eba74549e1fc484c83684ceb2285bc717f (diff) |
Merge "Fix FastNative/CriticalNative annotation lookup."
-rw-r--r-- | runtime/dex_file_annotations.cc | 21 | ||||
-rw-r--r-- | test/knownfailures.json | 7 |
2 files changed, 11 insertions, 17 deletions
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc index b556745a1b..4225ab9b6e 100644 --- a/runtime/dex_file_annotations.cc +++ b/runtime/dex_file_annotations.cc @@ -761,15 +761,16 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( } const uint8_t* annotation = annotation_item->annotation_; uint32_t type_index = DecodeUnsignedLeb128(&annotation); + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + Thread* self = Thread::Current(); mirror::Class* resolved_class; if (lookup_in_resolved_boot_classes) { + // Note: We cannot use ClassLinker::LookupResolvedType() because the current DexCache + // may not be registered with the boot class path ClassLoader and we must not pollute + // the DexCache with classes that are not in the associated ClassLoader's ClassTable. + const char* descriptor = dex_file.StringByTypeIdx(dex::TypeIndex(type_index)); ObjPtr<mirror::Class> looked_up_class = - Runtime::Current()->GetClassLinker()->LookupResolvedType( - klass.GetDexFile(), - dex::TypeIndex(type_index), - klass.GetDexCache(), - // Force the use of the bootstrap class loader. - static_cast<mirror::ClassLoader*>(nullptr)); + class_linker->LookupClass(self, descriptor, /* class_loader */ nullptr); resolved_class = looked_up_class.Ptr(); if (resolved_class == nullptr) { // If `resolved_class` is null, this is fine: just ignore that @@ -778,8 +779,8 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( continue; } } else { - StackHandleScope<2> hs(Thread::Current()); - resolved_class = Runtime::Current()->GetClassLinker()->ResolveType( + StackHandleScope<2> hs(self); + resolved_class = class_linker->ResolveType( klass.GetDexFile(), dex::TypeIndex(type_index), hs.NewHandle(klass.GetDexCache()), @@ -788,8 +789,8 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet( std::string temp; LOG(WARNING) << StringPrintf("Unable to resolve %s annotation class %d", klass.GetRealClass()->GetDescriptor(&temp), type_index); - CHECK(Thread::Current()->IsExceptionPending()); - Thread::Current()->ClearException(); + CHECK(self->IsExceptionPending()); + self->ClearException(); continue; } } diff --git a/test/knownfailures.json b/test/knownfailures.json index 09e76fa8ea..5a67fbcc45 100644 --- a/test/knownfailures.json +++ b/test/knownfailures.json @@ -707,13 +707,6 @@ "variant": "gcstress & jit & target" }, { - "tests": ["004-JniTest"], - "description": [ "Tests failing with --build-with-javac-dx since the new annotation", - "lookup changes" ], - "bug": "b/63089991", - "env_vars": {"ANDROID_COMPILE_WITH_JACK": "false"} - }, - { "tests": "660-clinit", "variant": "no-image | no-dex2oat | no-prebuild", "description": ["Tests <clinit> for app images, which --no-image, --no-prebuild and", |