From cd556b003adbb53739d4b3f43135e6a0ae69509a Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 3 Feb 2017 11:47:34 +0000 Subject: Fix dex cache resolved types and class table mismatch. Record class table in ClassLinker::DexCacheData and use it in DexCache.setResolvedType() to store the type also in the initiating loader's class table if the dex file has been registered. Also throw InternalError when trying to register the same DexFile with multiple class loaders. (Different DexFile instances referencing the same file are OK.) Test: 155-java-set-resolved-type Test: m test-art-host Bug: 30627598 Bug: 34193123 Bug: 34839984 Change-Id: Ia48acb300337c45880ea1459d2d32789546d67f4 --- runtime/class_table.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'runtime/class_table.cc') diff --git a/runtime/class_table.cc b/runtime/class_table.cc index ff846a718e..1f9dc8c6ee 100644 --- a/runtime/class_table.cc +++ b/runtime/class_table.cc @@ -123,6 +123,19 @@ mirror::Class* ClassTable::Lookup(const char* descriptor, size_t hash) { return nullptr; } +ObjPtr ClassTable::TryInsert(ObjPtr klass) { + TableSlot slot(klass); + WriterMutexLock mu(Thread::Current(), lock_); + for (ClassSet& class_set : classes_) { + auto it = class_set.Find(slot); + if (it != class_set.end()) { + return it->Read(); + } + } + classes_.back().Insert(slot); + return klass; +} + void ClassTable::Insert(ObjPtr klass) { const uint32_t hash = TableSlot::HashDescriptor(klass); WriterMutexLock mu(Thread::Current(), lock_); -- cgit v1.2.3-59-g8ed1b