Make test 1934 not flaky.
Test 1934 was slightly flaky since if the target thread is stopped
during a class-load you would get a ExceptionInInitializerError
(or a DCHECK failure) instead of the expected error. This change
removes the DCHECK if we are using AsyncExceptions and force the class
to be initialized before running the test.
Test: ./test.py --host -j50
Bug: 74446036
Change-Id: I164611f08c7a6ba4ea127cda6cf1df3dca25f08d
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index bf0d3ad..72c110a 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -268,9 +268,13 @@
// cannot in general be guaranteed, but in all likelihood leads to breakage down the line.
if (klass->GetClassLoader() == nullptr && !Runtime::Current()->IsAotCompiler()) {
std::string tmp;
- LOG(kIsDebugBuild ? FATAL : WARNING) << klass->GetDescriptor(&tmp)
- << " failed initialization: "
- << self->GetException()->Dump();
+ // We want to LOG(FATAL) on debug builds since this really shouldn't be happening but we need to
+ // make sure to only do it if we don't have AsyncExceptions being thrown around since those
+ // could have caused the error.
+ bool known_impossible = kIsDebugBuild && !Runtime::Current()->AreAsyncExceptionsThrown();
+ LOG(known_impossible ? FATAL : WARNING) << klass->GetDescriptor(&tmp)
+ << " failed initialization: "
+ << self->GetException()->Dump();
}
env->ExceptionClear();