110 |
110 |
111 //------------------------------------------------------------------------------ |
111 //------------------------------------------------------------------------------ |
112 // MethodHandles::generate_adapters |
112 // MethodHandles::generate_adapters |
113 // |
113 // |
114 void MethodHandles::generate_adapters() { |
114 void MethodHandles::generate_adapters() { |
115 if (!EnableMethodHandles || SystemDictionary::MethodHandle_klass() == NULL) return; |
115 if (!EnableInvokeDynamic || SystemDictionary::MethodHandle_klass() == NULL) return; |
116 |
116 |
117 assert(_adapter_code == NULL, "generate only once"); |
117 assert(_adapter_code == NULL, "generate only once"); |
118 |
118 |
119 ResourceMark rm; |
119 ResourceMark rm; |
120 TraceTime timer("MethodHandles adapters generation", TraceStartupTime); |
120 TraceTime timer("MethodHandles adapters generation", TraceStartupTime); |
2577 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2577 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2578 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2578 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2579 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} |
2579 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)} |
2580 }; |
2580 }; |
2581 |
2581 |
2582 // More entry points specifically for EnableInvokeDynamic. |
|
2583 // FIXME: Remove methods2 after AllowTransitionalJSR292 is removed. |
2582 // FIXME: Remove methods2 after AllowTransitionalJSR292 is removed. |
2584 static JNINativeMethod methods2[] = { |
2583 static JNINativeMethod methods2[] = { |
2585 {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHN_registerBootstrap)}, |
2584 {CC"registerBootstrap", CC"("CLS MH")V", FN_PTR(MHN_registerBootstrap)}, |
2586 {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHN_getBootstrap)}, |
2585 {CC"getBootstrap", CC"("CLS")"MH, FN_PTR(MHN_getBootstrap)}, |
2587 {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHN_setCallSiteTarget)} |
2586 {CC"setCallSiteTarget", CC"("CST MH")V", FN_PTR(MHN_setCallSiteTarget)} |
2616 // This one function is exported, used by NativeLookup. |
2615 // This one function is exported, used by NativeLookup. |
2617 |
2616 |
2618 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2617 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2619 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
2618 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
2620 |
2619 |
2621 // note: this explicit warning-producing stuff will be replaced by auto-detection of the JSR 292 classes |
2620 if (!EnableInvokeDynamic) { |
2622 |
2621 warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable."); |
2623 if (!EnableMethodHandles) { |
|
2624 warning("JSR 292 method handles are disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles to enable."); |
|
2625 return; // bind nothing |
2622 return; // bind nothing |
2626 } |
2623 } |
2627 |
2624 |
2628 if (SystemDictionary::MethodHandleNatives_klass() != NULL && |
2625 if (SystemDictionary::MethodHandleNatives_klass() != NULL && |
2629 SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) { |
2626 SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) { |
2700 |
2697 |
2701 MethodHandles::generate_adapters(); |
2698 MethodHandles::generate_adapters(); |
2702 MethodHandles::set_enabled(true); |
2699 MethodHandles::set_enabled(true); |
2703 } |
2700 } |
2704 |
2701 |
2705 if (!EnableInvokeDynamic) { |
|
2706 warning("JSR 292 invokedynamic is disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic to enable."); |
|
2707 return; // bind nothing |
|
2708 } |
|
2709 |
|
2710 if (AllowTransitionalJSR292) { |
2702 if (AllowTransitionalJSR292) { |
2711 ThreadToNativeFromVM ttnfv(thread); |
2703 ThreadToNativeFromVM ttnfv(thread); |
2712 |
2704 |
2713 int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); |
2705 int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); |
2714 if (env->ExceptionOccurred()) { |
2706 if (env->ExceptionOccurred()) { |