Navigation Menu

Skip to content


8264918: [JVMCI] getVtableIndexForInterfaceMethod doesn't check that …
Browse files Browse the repository at this point in the history
…type and method are related

Reviewed-by: kvn
  • Loading branch information
Vladimir Ivanov committed Apr 9, 2021
1 parent f7a6c63 commit b3782ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Expand Up @@ -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()) {
Expand All @@ -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);

Expand Down
Expand Up @@ -116,17 +116,19 @@ private static Set<TestCase> createTestCases() {
// class not implementing iface
result.add(new TestCase(DoNotExtendClass.class,
SingleImplementerInterface.class, "defaultMethod", false));
SingleImplementerInterface.class, "defaultMethod", false,
// abstract class which doesn't implement iface
result.add(new TestCase(AbstractClass.class,
SingleImplementerInterface.class, "defaultMethod", false));
SingleImplementerInterface.class, "defaultMethod", false,
// 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,
return result;

Expand Down

1 comment on commit b3782ea

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.