diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index af72322ff4bf2..5f1de1c9221ef 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -710,8 +710,9 @@ C2V_END C2V_VMENTRY_0(jlong, getJObjectValue, (JNIEnv* env, jobject, jobject constant_jobject)) requireNotInHotSpot("getJObjectValue", JVMCI_CHECK_0); - if (!THREAD->has_last_Java_frame()) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot call getJObjectValue without Java frame anchor")); + // Ensure that we are not using the top-most JNIHandleBlock, which is never released. + if (!THREAD->has_last_Java_frame() && THREAD->active_handles()->pop_frame_link() == nullptr) { + JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot call getJObjectValue without Java frame anchor or a pushed JNI handle block")); } JVMCIObject constant = JVMCIENV->wrap(constant_jobject); Handle constant_value = JVMCIENV->asConstant(constant, JVMCI_CHECK_0);