mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
Add verification to check that invokespecial of an InterfaceMethodref names a method in a direct superinterface of the current class or interface in accordance with JSR 335, JVMS 4.9.2 Structural Constraints. Reviewed-by: acorn, hseigel, coleenp
This commit is contained in:
parent
b1e3461fe5
commit
28557bc30e
5 changed files with 71 additions and 3 deletions
|
@ -915,6 +915,25 @@ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method
|
|||
return;
|
||||
}
|
||||
|
||||
// check if invokespecial's interface method reference is in an indirect superinterface
|
||||
if (!current_klass.is_null() && resolved_klass->is_interface()) {
|
||||
Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ?
|
||||
current_klass() :
|
||||
InstanceKlass::cast(current_klass())->host_klass();
|
||||
|
||||
if (!InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) {
|
||||
ResourceMark rm(THREAD);
|
||||
char buf[200];
|
||||
jio_snprintf(buf, sizeof(buf),
|
||||
"Interface method reference: %s, is in an indirect superinterface of %s",
|
||||
Method::name_and_sig_as_C_string(resolved_klass(),
|
||||
resolved_method->name(),
|
||||
resolved_method->signature()),
|
||||
current_klass->external_name());
|
||||
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
|
||||
}
|
||||
}
|
||||
|
||||
// check if not static
|
||||
if (resolved_method->is_static()) {
|
||||
ResourceMark rm(THREAD);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue