Fix inserting classes to initiating loader's class table.
Fix two cases that were missed in
https://android-review.googlesource.com/312285
First, copy all class references to app image class table,
including boot image classes where the class loader used for
AOT is only the initiating loader, not the defining loader.
Second, add array classes to the initiating loader's class
table.
Without these fixes, ClassLinker::LookupResolvedType() was
actually relying on the type being in the dex cache because
in some cases the slow path would not be able to find it.
Add a test for ClassLinker::LookupResolvedType() with an
array type and fix that function to avoid null pointer
dereference.
Test: m test-art-host
Bug: 30627598
Change-Id: I7cb14788700e6a22d16c364f8a35e2b6b3d954e4
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index 0f985c6..ff846a7 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -129,6 +129,19 @@
classes_.back().InsertWithHash(TableSlot(klass, hash), hash);
}
+void ClassTable::CopyWithoutLocks(const ClassTable& source_table) {
+ if (kIsDebugBuild) {
+ for (ClassSet& class_set : classes_) {
+ CHECK(class_set.Empty());
+ }
+ }
+ for (const ClassSet& class_set : source_table.classes_) {
+ for (const TableSlot& slot : class_set) {
+ classes_.back().Insert(slot);
+ }
+ }
+}
+
void ClassTable::InsertWithoutLocks(ObjPtr<mirror::Class> klass) {
const uint32_t hash = TableSlot::HashDescriptor(klass);
classes_.back().InsertWithHash(TableSlot(klass, hash), hash);