8180711: Better invokespecial checks
Reviewed-by: acorn, ahgross, rhalade
This commit is contained in:
parent
020204a972
commit
4dc1883cb7
src/hotspot/share/interpreter
@ -1074,11 +1074,7 @@ void LinkResolver::resolve_special_call(CallInfo& result,
|
|||||||
const LinkInfo& link_info,
|
const LinkInfo& link_info,
|
||||||
TRAPS) {
|
TRAPS) {
|
||||||
methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK);
|
methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK);
|
||||||
runtime_resolve_special_method(result, resolved_method,
|
runtime_resolve_special_method(result, link_info, resolved_method, recv, CHECK);
|
||||||
link_info.resolved_klass(),
|
|
||||||
link_info.current_klass(),
|
|
||||||
recv,
|
|
||||||
link_info.check_access(), CHECK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// throws linktime exceptions
|
// throws linktime exceptions
|
||||||
@ -1162,11 +1158,11 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_
|
|||||||
|
|
||||||
// throws runtime exceptions
|
// throws runtime exceptions
|
||||||
void LinkResolver::runtime_resolve_special_method(CallInfo& result,
|
void LinkResolver::runtime_resolve_special_method(CallInfo& result,
|
||||||
|
const LinkInfo& link_info,
|
||||||
const methodHandle& resolved_method,
|
const methodHandle& resolved_method,
|
||||||
Klass* resolved_klass,
|
Handle recv, TRAPS) {
|
||||||
Klass* current_klass,
|
|
||||||
Handle recv,
|
Klass* resolved_klass = link_info.resolved_klass();
|
||||||
bool check_access, TRAPS) {
|
|
||||||
|
|
||||||
// resolved method is selected method unless we have an old-style lookup
|
// resolved method is selected method unless we have an old-style lookup
|
||||||
// for a superclass method
|
// for a superclass method
|
||||||
@ -1174,12 +1170,13 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
|
|||||||
// no checks for shadowing
|
// no checks for shadowing
|
||||||
methodHandle sel_method(THREAD, resolved_method());
|
methodHandle sel_method(THREAD, resolved_method());
|
||||||
|
|
||||||
if (check_access &&
|
if (link_info.check_access() &&
|
||||||
// check if the method is not <init>
|
// check if the method is not <init>
|
||||||
resolved_method->name() != vmSymbols::object_initializer_name()) {
|
resolved_method->name() != vmSymbols::object_initializer_name()) {
|
||||||
|
|
||||||
// check if this is an old-style super call and do a new lookup if so
|
// check if this is an old-style super call and do a new lookup if so
|
||||||
// a) check if ACC_SUPER flag is set for the current class
|
// a) check if ACC_SUPER flag is set for the current class
|
||||||
|
Klass* current_klass = link_info.current_klass();
|
||||||
if ((current_klass->is_super() || !AllowNonVirtualCalls) &&
|
if ((current_klass->is_super() || !AllowNonVirtualCalls) &&
|
||||||
// b) check if the class of the resolved_klass is a superclass
|
// b) check if the class of the resolved_klass is a superclass
|
||||||
// (not supertype in order to exclude interface classes) of the current class.
|
// (not supertype in order to exclude interface classes) of the current class.
|
||||||
@ -1199,6 +1196,9 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
|
|||||||
Method::name_and_sig_as_C_string(resolved_klass,
|
Method::name_and_sig_as_C_string(resolved_klass,
|
||||||
resolved_method->name(),
|
resolved_method->name(),
|
||||||
resolved_method->signature()));
|
resolved_method->signature()));
|
||||||
|
// check loader constraints if found a different method
|
||||||
|
} else if (sel_method() != resolved_method()) {
|
||||||
|
check_method_loader_constraints(link_info, sel_method, "method", CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +233,10 @@ class LinkResolver: AllStatic {
|
|||||||
static methodHandle linktime_resolve_interface_method (const LinkInfo& link_info, TRAPS);
|
static methodHandle linktime_resolve_interface_method (const LinkInfo& link_info, TRAPS);
|
||||||
|
|
||||||
static void runtime_resolve_special_method (CallInfo& result,
|
static void runtime_resolve_special_method (CallInfo& result,
|
||||||
|
const LinkInfo& link_info,
|
||||||
const methodHandle& resolved_method,
|
const methodHandle& resolved_method,
|
||||||
Klass* resolved_klass,
|
Handle recv, TRAPS);
|
||||||
Klass* current_klass,
|
|
||||||
Handle recv,
|
|
||||||
bool check_access, TRAPS);
|
|
||||||
static void runtime_resolve_virtual_method (CallInfo& result,
|
static void runtime_resolve_virtual_method (CallInfo& result,
|
||||||
const methodHandle& resolved_method,
|
const methodHandle& resolved_method,
|
||||||
Klass* resolved_klass,
|
Klass* resolved_klass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user