summaryrefslogtreecommitdiff
path: root/runtime/class_table.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-02-03 11:47:34 +0000
committer Vladimir Marko <vmarko@google.com> 2017-02-09 10:10:29 +0000
commitcd556b003adbb53739d4b3f43135e6a0ae69509a (patch)
treea30c9f03071d87e1f75a0d0b8c2961d113ea767d /runtime/class_table.cc
parent357dcb73934356239292c46d6fbedba734da5e00 (diff)
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
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r--runtime/class_table.cc13
1 files changed, 13 insertions, 0 deletions
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<mirror::Class> ClassTable::TryInsert(ObjPtr<mirror::Class> 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<mirror::Class> klass) {
const uint32_t hash = TableSlot::HashDescriptor(klass);
WriterMutexLock mu(Thread::Current(), lock_);