Suspend around Make...VisiblyInitialized

Remove the workarounds introduced in aosp/2212326, and replace them
with actual fixes. Also requires an additional handle introduction in
UnstartedClassForNameTest.

After this, we no longer disable thread state checking in any
MakeInitializedClassesVisiblyInitialized calls. Remove the mechanism
to do so.

Test: Build and boot AOSP.
Bug: 253691761
Change-Id: I4449c8715e154db504eb94d2da631428bfb52de4
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index e7e5554..64f6e64 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -131,12 +131,14 @@
     EXPECT_TRUE(JavaLangObject->GetSuperClass() == nullptr);
     EXPECT_FALSE(JavaLangObject->HasSuperClass());
     EXPECT_TRUE(JavaLangObject->GetClassLoader() == nullptr);
-    // TODO(b/253691761): Remove the last argument to MakeInitializedClassesVisiblyInitial when
-    // possible. We should not be holding the mutator lock here, but temporarily releasing it
-    // would compromise the ObjPtr argument.
-    class_linker_->MakeInitializedClassesVisiblyInitialized(Thread::Current(),
-                                                            /*wait=*/ true,
-                                                            /*allowLockChecking=*/ false);
+    {
+      Thread* self = Thread::Current();
+      StackHandleScope<1> hs(self);
+      HandleWrapperObjPtr<mirror::Class> h(hs.NewHandleWrapper(&JavaLangObject));
+      ScopedThreadSuspension sts(self, ThreadState::kNative);
+      class_linker_->MakeInitializedClassesVisiblyInitialized(self, /*wait=*/ true);
+      // HandleWrapperObjPtr restores JavaLangObject here after becoming runnable again.
+    }
     EXPECT_EQ(ClassStatus::kVisiblyInitialized, JavaLangObject->GetStatus());
     EXPECT_FALSE(JavaLangObject->IsErroneous());
     EXPECT_TRUE(JavaLangObject->IsLoaded());