Make InitializeStaticStorageFromCode handle requests for uninitialized storage from <clinit>
Change-Id: I8562ad4fdb33c02c575ddc8986e49ee37c566cfd
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 8ddcc5f..7cd320e 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1390,9 +1390,16 @@
if (klass == NULL) {
UNIMPLEMENTED(FATAL) << "throw exception due to unresolved class";
}
+ // If we are the <clinit> of this class, just return our storage.
+ //
+ // Do not set the DexCache InitializedStaticStorage, since that
+ // implies <clinit> has finished running.
+ if (klass == referrer->GetDeclaringClass() && referrer->GetName()->Equals("<clinit>")) {
+ return klass;
+ }
if (!class_linker->EnsureInitialized(klass)) {
CHECK(Thread::Current()->IsExceptionPending());
- UNIMPLEMENTED(FATAL) << "throw exception due to class initializtion problem";
+ UNIMPLEMENTED(FATAL) << "throw exception due to class initialization problem";
}
referrer->GetDexCacheInitializedStaticStorage()->Set(type_idx, klass);
return klass;