summaryrefslogtreecommitdiff
path: root/runtime/class_linker_test.cc
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2022-10-17 17:21:45 -0700
committer Hans Boehm <hboehm@google.com> 2022-10-19 18:09:38 +0000
commit0f82baeb17079c5146181df6ae7f61b7357e9c7f (patch)
tree9670479deff6b9ae58a5252face4fd6f1274dda3 /runtime/class_linker_test.cc
parent76d463293da40d619f35f8999869fab692be4772 (diff)
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
Diffstat (limited to 'runtime/class_linker_test.cc')
-rw-r--r--runtime/class_linker_test.cc14
1 files changed, 8 insertions, 6 deletions
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<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());