8189633: Missing -Xcheck:jni checking for DeleteWeakGlobalRef
Summary: Added validity check on the handle before deleting it.
Reviewed-by: dholmes, dcubed
--- a/src/hotspot/share/prims/jniCheck.cpp Wed Aug 21 18:42:30 2019 -0400
+++ b/src/hotspot/share/prims/jniCheck.cpp Wed Aug 21 19:21:57 2019 -0400
@@ -1927,6 +1927,12 @@
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