diff a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1634,10 +1634,15 @@ WB_ENTRY(void, WB_RelocateNMethodFromMethod(JNIEnv* env, jobject o, jobject method, jint blob_type)) ResourceMark rm(THREAD); jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION(env); + + if (!NMethodRelocation) { + return; + } + methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); nmethod* code = mh->code(); if (code != nullptr) { MutexLocker ml_Compile_lock(Compile_lock); CompiledICLocker ic_locker(code); @@ -1653,10 +1658,14 @@ if (address == nullptr) { return; } + if (!NMethodRelocation) { + return; + } + MutexLocker ml_Compile_lock(Compile_lock); MutexLocker ml_CompiledIC_lock(CompiledIC_lock, Mutex::_no_safepoint_check_flag); MutexLocker ml_CodeCache_lock(CodeCache_lock, Mutex::_no_safepoint_check_flag); // Verify that nmethod address is still valid