Handle OOMEs in class linker with grace.
Check for OOMEs and then fail due to them in class loading.
Make the compiler driver spot OOMEs during resolution and abort compilation to
avoid needless GC thrash then eventual death.
Allocate the pre-allocated OOME during Runtime::Init as Runtime::Start isn't
called in the context of the compiler/tools.
Change-Id: Id72199d0fe82001b5bf22758b3cdc9cc4b8efbb9
diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h
index 6f22618..abc88a3 100644
--- a/runtime/mirror/object_array-inl.h
+++ b/runtime/mirror/object_array-inl.h
@@ -135,7 +135,9 @@
template<class T>
inline ObjectArray<T>* ObjectArray<T>::CopyOf(Thread* self, int32_t new_length) {
ObjectArray<T>* new_array = Alloc(self, GetClass(), new_length);
- Copy(this, 0, new_array, 0, std::min(GetLength(), new_length));
+ if (LIKELY(new_array != NULL)) {
+ Copy(this, 0, new_array, 0, std::min(GetLength(), new_length));
+ }
return new_array;
}