Skip to content

Commit

Permalink
Merge pull request #11241 from DanHeidinga/djh/unsafejni
Browse files Browse the repository at this point in the history
Fetch array length before dropping vm access
  • Loading branch information
gacholio committed Nov 20, 2020
2 parents ac22731 + 7917f50 commit 749f941
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/jcl/common/sun_misc_Unsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ Java_sun_misc_Unsafe_defineAnonymousClass(JNIEnv *env, jobject receiver, jclass
}
}

vmFuncs->internalExitVMToJNI(currentThread);
jsize length = (jsize)J9INDEXABLEOBJECT_SIZE(currentThread, J9_JNI_UNWRAP_REFERENCE(bytecodes));

jsize length = env->GetArrayLength(bytecodes);
vmFuncs->internalExitVMToJNI(currentThread);

/* acquires access internally */
jclass anonClass = defineClassCommon(env, hostClassLoaderLocalRef, NULL,bytecodes, 0, length, protectionDomainLocalRef, &defineClassOptions, hostClazz, &cpPatchMap, FALSE);
jclass anonClass = defineClassCommon(env, hostClassLoaderLocalRef, NULL, bytecodes, 0, length, protectionDomainLocalRef, &defineClassOptions, hostClazz, &cpPatchMap, FALSE);
if (env->ExceptionCheck()) {
return NULL;
} else if (NULL == anonClass) {
Expand Down

0 comments on commit 749f941

Please sign in to comment.