--- old/src/hotspot/share/runtime/jniHandles.cpp 2017-11-16 08:27:18.597964320 -0500 +++ new/src/hotspot/share/runtime/jniHandles.cpp 2017-11-16 08:27:18.423425126 -0500 @@ -47,6 +47,7 @@ } else { Thread* thread = Thread::current(); assert(Universe::heap()->is_in_reserved(obj), "sanity check"); + assert(JavaThread::current()->thread_state() != _thread_in_native, "must not be in native"); return thread->active_handles()->allocate_handle(obj); } } @@ -59,6 +60,8 @@ return NULL; // ignore null handles } else { assert(Universe::heap()->is_in_reserved(obj), "sanity check"); + assert(thread->is_Java_thread(), "not a Java thread"); + assert(((JavaThread *)thread)->thread_state() != _thread_in_native, "must not be in native"); return thread->active_handles()->allocate_handle(obj); } } @@ -70,6 +73,7 @@ } else { JavaThread* thread = JavaThread::thread_from_jni_environment(env); assert(Universe::heap()->is_in_reserved(obj), "sanity check"); + assert(thread->thread_state() != _thread_in_native, "must not be in native"); return thread->active_handles()->allocate_handle(obj); } } @@ -77,6 +81,7 @@ jobject JNIHandles::make_global(Handle obj) { assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); + assert(JavaThread::current()->thread_state() != _thread_in_native, "must not be in native"); jobject res = NULL; if (!obj.is_null()) { // ignore null handles @@ -93,6 +98,7 @@ jobject JNIHandles::make_weak_global(Handle obj) { assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); + assert(JavaThread::current()->thread_state() != _thread_in_native, "must not be in native"); jobject res = NULL; if (!obj.is_null()) { // ignore null handles