diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 8de19ea906f..f111f227887 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -1927,6 +1927,12 @@ JNI_ENTRY_CHECKED(void, checked_jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) functionEnterExceptionAllowed(thr); + IN_VM( + if (ref && !JNIHandles::is_weak_global_handle(ref)) { + ReportJNIFatalError(thr, + "Invalid weak global JNI handle passed to DeleteWeakGlobalRef"); + } + ) UNCHECKED()->DeleteWeakGlobalRef(env, ref); functionExit(thr); JNI_END