Check for null thread groups at initialization
Change-Id: Ia6fffe9f416ac4bd2588016b99b172cf023f3c5d
diff --git a/src/runtime.cc b/src/runtime.cc
index ae4f16e..6447ede 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -770,9 +770,21 @@
main_thread_group_ =
env->NewGlobalRef(env->GetStaticObjectField(WellKnownClasses::java_lang_ThreadGroup,
WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup));
+ CHECK(main_thread_group_ != NULL || IsCompiler());
system_thread_group_ =
env->NewGlobalRef(env->GetStaticObjectField(WellKnownClasses::java_lang_ThreadGroup,
WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup));
+ CHECK(system_thread_group_ != NULL || IsCompiler());
+}
+
+jobject Runtime::GetMainThreadGroup() const {
+ CHECK(main_thread_group_ != NULL || IsCompiler());
+ return main_thread_group_;
+}
+
+jobject Runtime::GetSystemThreadGroup() const {
+ CHECK(system_thread_group_ != NULL || IsCompiler());
+ return system_thread_group_;
}
void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) {
diff --git a/src/runtime.h b/src/runtime.h
index c583ab1..544dcf4 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -141,16 +141,10 @@
static void Abort();
// Returns the "main" ThreadGroup, used when attaching user threads.
- jobject GetMainThreadGroup() const {
- CHECK(main_thread_group_ != NULL || IsCompiler());
- return main_thread_group_;
- }
+ jobject GetMainThreadGroup() const;
// Returns the "system" ThreadGroup, used when attaching our internal threads.
- jobject GetSystemThreadGroup() const {
- CHECK(system_thread_group_ != NULL || IsCompiler());
- return system_thread_group_;
- }
+ jobject GetSystemThreadGroup() const;
// Attaches the calling native thread to the runtime.
void AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group);