8264918: [JVMCI] getVtableIndexForInterfaceMethod doesn't check that type and method are related
Reviewed-by: kvn
This commit is contained in:
parent
f7a6c63ad3
commit
b3782ead36
@ -729,10 +729,11 @@ C2V_END
|
||||
C2V_VMENTRY_0(jint, getVtableIndexForInterfaceMethod, (JNIEnv* env, jobject, jobject jvmci_type, jobject jvmci_method))
|
||||
Klass* klass = JVMCIENV->asKlass(jvmci_type);
|
||||
methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
|
||||
InstanceKlass* holder = method->method_holder();
|
||||
if (klass->is_interface()) {
|
||||
JVMCI_THROW_MSG_0(InternalError, err_msg("Interface %s should be handled in Java code", klass->external_name()));
|
||||
}
|
||||
if (!method->method_holder()->is_interface()) {
|
||||
if (!holder->is_interface()) {
|
||||
JVMCI_THROW_MSG_0(InternalError, err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string()));
|
||||
}
|
||||
if (!klass->is_instance_klass()) {
|
||||
@ -741,6 +742,9 @@ C2V_VMENTRY_0(jint, getVtableIndexForInterfaceMethod, (JNIEnv* env, jobject, job
|
||||
if (!InstanceKlass::cast(klass)->is_linked()) {
|
||||
JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be linked", klass->external_name()));
|
||||
}
|
||||
if (!klass->is_subtype_of(holder)) {
|
||||
JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s does not implement interface %s", klass->external_name(), holder->external_name()));
|
||||
}
|
||||
return LinkResolver::vtable_index_of_interface_method(klass, method);
|
||||
C2V_END
|
||||
|
||||
|
@ -116,17 +116,19 @@ public class GetVtableIndexForInterfaceTest {
|
||||
InternalError.class));
|
||||
// class not implementing iface
|
||||
result.add(new TestCase(DoNotExtendClass.class,
|
||||
SingleImplementerInterface.class, "defaultMethod", false));
|
||||
SingleImplementerInterface.class, "defaultMethod", false,
|
||||
InternalError.class));
|
||||
// abstract class which doesn't implement iface
|
||||
result.add(new TestCase(AbstractClass.class,
|
||||
SingleImplementerInterface.class, "defaultMethod", false));
|
||||
SingleImplementerInterface.class, "defaultMethod", false,
|
||||
InternalError.class));
|
||||
// abstract class which implements iface
|
||||
result.add(new TestCase(MultipleAbstractImplementer.class,
|
||||
MultipleImplementersInterface.class, "defaultMethod", true));
|
||||
// class not initialized
|
||||
result.add(new TestCase(AnotherSingleImplementer.class,
|
||||
AnotherSingleImplementerInterface.class, "defaultMethod",
|
||||
false, InternalError.class));
|
||||
AnotherSingleImplementerInterface.class, "defaultMethod", false,
|
||||
InternalError.class));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user