Make array class with erroneous component also erroneous under AOT.
We cannot encode such array classes in an image, so just prevent
creating them.
Test: test.py
Test: image_test
Bug: 240582357
Change-Id: I2efdf3cc7bc72169713eb9b849824d71145764ac
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 78aac8b..51870a7 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4143,10 +4143,11 @@
class_loader)));
if (component_type == nullptr) {
DCHECK(self->IsExceptionPending());
- // We need to accept erroneous classes as component types.
+ // We need to accept erroneous classes as component types. Under AOT, we
+ // don't accept them as we cannot encode the erroneous class in an image.
const size_t component_hash = ComputeModifiedUtf8Hash(descriptor + 1);
component_type.Assign(LookupClass(self, descriptor + 1, component_hash, class_loader.Get()));
- if (component_type == nullptr) {
+ if (component_type == nullptr || Runtime::Current()->IsAotCompiler()) {
DCHECK(self->IsExceptionPending());
return nullptr;
} else {