Don't initialize at AOT time classes that need access checks.

The compiler driver currently cannot handle it.

Test: SuperWithAccessChecks
Bug: 242151549
Change-Id: I3f3f72ea4f21851eabad5d7f8a05764f3ee842da
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index ccf4ff2..dc67dca 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -5088,11 +5088,19 @@
   CHECK_EQ(prototype, method->GetInterfaceMethodIfProxy(image_pointer_size_));
 }
 
-bool ClassLinker::CanWeInitializeClass(ObjPtr<mirror::Class> klass, bool can_init_statics,
+bool ClassLinker::CanWeInitializeClass(ObjPtr<mirror::Class> klass,
+                                       bool can_init_statics,
                                        bool can_init_parents) {
   if (can_init_statics && can_init_parents) {
     return true;
   }
+  DCHECK(Runtime::Current()->IsAotCompiler());
+
+  // We currently don't support initializing at AOT time classes that need access
+  // checks.
+  if (klass->IsVerifiedNeedsAccessChecks()) {
+    return false;
+  }
   if (!can_init_statics) {
     // Check if there's a class initializer.
     ArtMethod* clinit = klass->FindClassInitializer(image_pointer_size_);