From 4e99b3d8955131f3fc71aa113f0fa71f0092cb6f Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Tue, 24 Jun 2014 14:35:40 +0200 Subject: Add missing class initialization during compilation and tests Adds missing class initialization during compilation and tests, especially java.lang.Class. Otherwise, we'd be able to execute code while the referring class is not initialized or initializing. Also adds mirror::Class::AssertInitializedOrInitializingInThread method to check class initialization when entering the interpreter: the called method's declaring class must either be initialized or be initializing by the current thread (other threads must be waiting for the class initialization to complete holding its lock). Note we only do this check in debug build. Bump oat version to force compilation. Bug: 15899971 Change-Id: I9a4edd3739a3ca4cf1c4929dcbb44cdf7a1ca1fe --- runtime/mirror/class-inl.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime/mirror/class-inl.h') diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 451235c327..2daa6e49a6 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -546,6 +546,14 @@ inline bool Class::DescriptorEquals(const char* match) { } } +inline void Class::AssertInitializedOrInitializingInThread(Thread* self) { + if (kIsDebugBuild && !IsInitialized()) { + CHECK(IsInitializing()) << PrettyClass(this) << " is not initializing: " << GetStatus(); + CHECK_EQ(GetClinitThreadId(), self->GetTid()) << PrettyClass(this) + << " is initializing in a different thread"; + } +} + } // namespace mirror } // namespace art -- cgit v1.2.3-59-g8ed1b