Fix 084-class-init
Don't update the code and direct methods table for classes that are
still initializing as a 2nd thread may need to wait for class
initialization.
Fix the return value of EnsureInitialized when the class initializer
throws an exception.
Change-Id: I571d983f1a4025b5bcdd51b817d252ef131a6e97
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 14f4b7e..045974f 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2067,12 +2067,14 @@
uint64_t t1 = NanoTime();
+ bool success = true;
{
ObjectLock lock(klass);
if (self->IsExceptionPending()) {
WrapExceptionInInitializer();
klass->SetStatus(Class::kStatusError);
+ success = false;
} else {
RuntimeStats* global_stats = Runtime::Current()->GetStats();
RuntimeStats* thread_stats = self->GetStats();
@@ -2088,8 +2090,7 @@
}
lock.NotifyAll();
}
-
- return true;
+ return success;
}
bool ClassLinker::WaitForInitializeClass(Class* klass, Thread* self, ObjectLock& lock) {