3163 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { 3164 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); 3165 3166 if (!EnableInvokeDynamic) { 3167 warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable."); 3168 return; // bind nothing 3169 } 3170 3171 assert(!MethodHandles::enabled(), "must not be enabled"); 3172 bool enable_MH = true; 3173 3174 { 3175 ThreadToNativeFromVM ttnfv(thread); 3176 int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod)); 3177 if (!env->ExceptionOccurred()) { 3178 const char* L_MH_name = (JLINV "MethodHandle"); 3179 const char* MH_name = L_MH_name+1; 3180 jclass MH_class = env->FindClass(MH_name); 3181 status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod)); 3182 } 3183 if (env->ExceptionOccurred()) { 3184 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); 3185 enable_MH = false; 3186 env->ExceptionClear(); 3187 } 3188 3189 status = env->RegisterNatives(MHN_class, call_site_methods, sizeof(call_site_methods)/sizeof(JNINativeMethod)); 3190 if (env->ExceptionOccurred()) { 3191 // Exception is okay until 7087357 3192 env->ExceptionClear(); 3193 } 3194 } 3195 3196 if (enable_MH) { 3197 methodOop raiseException_method = MethodHandles::resolve_raise_exception_method(CHECK); 3198 if (raiseException_method != NULL) { 3199 MethodHandles::set_raise_exception_method(raiseException_method); 3200 } else { 3201 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); 3202 enable_MH = false; 3203 } 3204 } 3205 3206 if (enable_MH) { 3207 MethodHandles::generate_adapters(); 3208 MethodHandles::set_enabled(true); 3209 } 3210 } 3211 JVM_END | 3163 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { 3164 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); 3165 3166 if (!EnableInvokeDynamic) { 3167 warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable."); 3168 return; // bind nothing 3169 } 3170 3171 assert(!MethodHandles::enabled(), "must not be enabled"); 3172 bool enable_MH = true; 3173 3174 { 3175 ThreadToNativeFromVM ttnfv(thread); 3176 int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod)); 3177 if (!env->ExceptionOccurred()) { 3178 const char* L_MH_name = (JLINV "MethodHandle"); 3179 const char* MH_name = L_MH_name+1; 3180 jclass MH_class = env->FindClass(MH_name); 3181 status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod)); 3182 } 3183 if (!env->ExceptionOccurred()) { 3184 status = env->RegisterNatives(MHN_class, call_site_methods, sizeof(call_site_methods)/sizeof(JNINativeMethod)); 3185 } 3186 if (env->ExceptionOccurred()) { 3187 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); 3188 enable_MH = false; 3189 env->ExceptionClear(); 3190 } 3191 3192 } 3193 3194 if (enable_MH) { 3195 methodOop raiseException_method = MethodHandles::resolve_raise_exception_method(CHECK); 3196 if (raiseException_method != NULL) { 3197 MethodHandles::set_raise_exception_method(raiseException_method); 3198 } else { 3199 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); 3200 enable_MH = false; 3201 } 3202 } 3203 3204 if (enable_MH) { 3205 MethodHandles::generate_adapters(); 3206 MethodHandles::set_enabled(true); 3207 } 3208 } 3209 JVM_END |