diff --git a/runtime/jcl/common/sun_misc_Unsafe.cpp b/runtime/jcl/common/sun_misc_Unsafe.cpp index 5ec78037a18..78c2b999905 100644 --- a/runtime/jcl/common/sun_misc_Unsafe.cpp +++ b/runtime/jcl/common/sun_misc_Unsafe.cpp @@ -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) {