diff --git a/src/share/vm/runtime/java.cpp b/src/share/vm/runtime/java.cpp index 6abdd64d59953ad9ae666f7e73c2924e3bc1264e..f6b20a7b79e4fd1d51d0e0a30b00d673921e7399 100644 --- a/src/share/vm/runtime/java.cpp +++ b/src/share/vm/runtime/java.cpp @@ -515,8 +515,8 @@ void before_exit(JavaThread * thread) { } void vm_exit(int code) { - Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL - : ThreadLocalStorage::get_thread_slow(); + Thread* thread = ThreadLocalStorage::is_initialized() ? + ThreadLocalStorage::get_thread_slow() : NULL; if (thread == NULL) { // we have serious problems -- just exit vm_direct_exit(code); @@ -553,8 +553,9 @@ void vm_perform_shutdown_actions() { // Calling 'exit_globals()' will disable thread-local-storage and cause all // kinds of assertions to trigger in debug mode. if (is_init_completed()) { - Thread* thread = Thread::current(); - if (thread->is_Java_thread()) { + Thread* thread = ThreadLocalStorage::is_initialized() ? + ThreadLocalStorage::get_thread_slow() : NULL; + if (thread != NULL && thread->is_Java_thread()) { // We are leaving the VM, set state to native (in case any OS exit // handlers call back to the VM) JavaThread* jt = (JavaThread*)thread;