From 0f82baeb17079c5146181df6ae7f61b7357e9c7f Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Mon, 17 Oct 2022 17:21:45 -0700 Subject: 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 --- runtime/class_linker_test.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'runtime/class_linker_test.cc') diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index e7e5554d7a..64f6e64aca 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -131,12 +131,14 @@ class ClassLinkerTest : public CommonRuntimeTest { 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 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()); -- cgit v1.2.3-59-g8ed1b