Skip to content

Commit

Permalink
8281866: Enhance MethodHandle invocations
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
Reviewed-by: chagedorn
  • Loading branch information
2 people authored and slowhog committed Jul 19, 2022
1 parent 84b4e9b commit 632d2d2
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/hotspot/share/interpreter/linkResolver.cpp
Expand Up @@ -1735,8 +1735,31 @@ void LinkResolver::resolve_handle_call(CallInfo& result,
resolved_klass == vmClasses::VarHandle_klass(), "");
assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), "");
Handle resolved_appendix;
Method* resolved_method = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK);
result.set_handle(resolved_klass, methodHandle(THREAD, resolved_method), resolved_appendix, CHECK);
Method* m = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK);
methodHandle resolved_method(THREAD, m);

if (link_info.check_access()) {
Symbol* name = link_info.name();
vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name);
if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) {
// Check if method can be accessed by the referring class.
// MH.linkTo* invocations are not rewritten to invokehandle.
assert(iid == vmIntrinsicID::_invokeBasic, "%s", vmIntrinsics::name_at(iid));

Klass* current_klass = link_info.current_klass();
assert(current_klass != NULL , "current_klass should not be null");
check_method_accessability(current_klass,
resolved_klass,
resolved_method->method_holder(),
resolved_method,
CHECK);
} else {
// Java code is free to arbitrarily link signature-polymorphic invokers.
assert(iid == vmIntrinsics::_invokeGeneric, "not an invoker: %s", vmIntrinsics::name_at(iid));
assert(MethodHandles::is_signature_polymorphic_public_name(resolved_klass, name), "not public");
}
}
result.set_handle(resolved_klass, resolved_method, resolved_appendix, CHECK);
JFR_ONLY(Jfr::on_resolution(result, CHECK);)
}

Expand Down

0 comments on commit 632d2d2

Please sign in to comment.