2277 return res; |
2277 return res; |
2278 } |
2278 } |
2279 JVM_END |
2279 JVM_END |
2280 |
2280 |
2281 |
2281 |
|
2282 JVM_ENTRY(void, MH_linkCallSite(JNIEnv *env, jobject igcls, jobject site_jh, jobject target_jh)) { |
|
2283 // No special action required, yet. |
|
2284 oop site_oop = JNIHandles::resolve(site_jh); |
|
2285 if (site_oop == NULL || site_oop->klass() != SystemDictionary::CallSiteImpl_klass()) |
|
2286 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "call site"); |
|
2287 sun_dyn_CallSiteImpl::set_target(site_oop, JNIHandles::resolve(target_jh)); |
|
2288 } |
|
2289 JVM_END |
|
2290 |
|
2291 |
2282 /// JVM_RegisterMethodHandleMethods |
2292 /// JVM_RegisterMethodHandleMethods |
2283 |
2293 |
2284 #define ADR "J" |
2294 #define ADR "J" |
2285 |
2295 |
2286 #define LANG "Ljava/lang/" |
2296 #define LANG "Ljava/lang/" |
2295 #define MHI IDYN"MethodHandleImpl;" |
2305 #define MHI IDYN"MethodHandleImpl;" |
2296 #define MEM IDYN"MemberName;" |
2306 #define MEM IDYN"MemberName;" |
2297 #define AMH IDYN"AdapterMethodHandle;" |
2307 #define AMH IDYN"AdapterMethodHandle;" |
2298 #define BMH IDYN"BoundMethodHandle;" |
2308 #define BMH IDYN"BoundMethodHandle;" |
2299 #define DMH IDYN"DirectMethodHandle;" |
2309 #define DMH IDYN"DirectMethodHandle;" |
|
2310 #define CSTI IDYN"CallSiteImpl;" |
2300 |
2311 |
2301 #define CC (char*) /*cast a literal from (const char*)*/ |
2312 #define CC (char*) /*cast a literal from (const char*)*/ |
2302 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) |
2313 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) |
2303 |
2314 |
2304 // These are the native methods on sun.dyn.MethodHandleNatives. |
2315 // These are the native methods on sun.dyn.MethodHandleNatives. |
2318 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2329 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
2319 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2330 // int matchFlags, Class<?> caller, int skip, MemberName[] results); |
2320 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHI_getMembers)} |
2331 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHI_getMembers)} |
2321 }; |
2332 }; |
2322 |
2333 |
|
2334 // More entry points specifically for EnableInvokeDynamic. |
|
2335 static JNINativeMethod methods2[] = { |
|
2336 {CC"linkCallSite", CC"("CSTI MH")V", FN_PTR(MH_linkCallSite)} |
|
2337 }; |
|
2338 |
2323 |
2339 |
2324 // This one function is exported, used by NativeLookup. |
2340 // This one function is exported, used by NativeLookup. |
2325 |
2341 |
2326 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2342 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2327 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
2343 assert(MethodHandles::spot_check_entry_names(), "entry enum is OK"); |
|
2344 |
|
2345 // note: this explicit warning-producing stuff will be replaced by auto-detection of the JSR 292 classes |
2328 |
2346 |
2329 if (!EnableMethodHandles) { |
2347 if (!EnableMethodHandles) { |
2330 warning("JSR 292 method handles are disabled in this JVM. Use -XX:+EnableMethodHandles to enable."); |
2348 warning("JSR 292 method handles are disabled in this JVM. Use -XX:+EnableMethodHandles to enable."); |
2331 return; // bind nothing |
2349 return; // bind nothing |
2332 } |
2350 } |
2341 env->ExceptionClear(); |
2359 env->ExceptionClear(); |
2342 } else { |
2360 } else { |
2343 MethodHandles::set_enabled(true); |
2361 MethodHandles::set_enabled(true); |
2344 } |
2362 } |
2345 } |
2363 } |
|
2364 |
|
2365 if (!EnableInvokeDynamic) { |
|
2366 warning("JSR 292 invokedynamic is disabled in this JVM. Use -XX:+EnableInvokeDynamic to enable."); |
|
2367 return; // bind nothing |
|
2368 } |
|
2369 |
|
2370 { |
|
2371 ThreadToNativeFromVM ttnfv(thread); |
|
2372 |
|
2373 int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); |
|
2374 if (env->ExceptionOccurred()) { |
|
2375 MethodHandles::set_enabled(false); |
|
2376 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); |
|
2377 env->ExceptionClear(); |
|
2378 } else { |
|
2379 MethodHandles::set_enabled(true); |
|
2380 } |
|
2381 } |
2346 } |
2382 } |
2347 JVM_END |
2383 JVM_END |