8212817: [JVMCI] ResolvedJavaMethod.isInVirtualMethodTable throws InternalError
authordnsimon
Tue, 23 Oct 2018 18:49:32 +0200
changeset 52230 fb01ea9dcee3
parent 52229 d8843761f478
child 52231 66432f0e91bd
8212817: [JVMCI] ResolvedJavaMethod.isInVirtualMethodTable throws InternalError Reviewed-by: never, iveresov
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java
--- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java	Tue Oct 23 09:43:16 2018 -0700
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java	Tue Oct 23 18:49:32 2018 +0200
@@ -725,7 +725,7 @@
             return config().invalidVtableIndex;
         }
         if (holder.isInterface()) {
-            if (resolved.isInterface()) {
+            if (resolved.isInterface() || !resolved.isLinked()) {
                 return config().invalidVtableIndex;
             }
             return getVtableIndexForInterfaceMethod(resolved);
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java	Tue Oct 23 09:43:16 2018 -0700
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java	Tue Oct 23 18:49:32 2018 +0200
@@ -429,11 +429,24 @@
         }
     }
 
+    static class UnlinkedType {
+    }
+
     /**
      * All public non-final methods should be available in the vtable.
      */
     @Test
     public void testVirtualMethodTableAccess() {
+        ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class);
+        assertTrue(!unlinkedType.isLinked());
+        for (Class<?> c : classes) {
+            if (c.isInterface()) {
+                for (Method m : c.getDeclaredMethods()) {
+                    ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
+                    method.isInVirtualMethodTable(unlinkedType);
+                }
+            }
+        }
         for (Class<?> c : classes) {
             if (c.isPrimitive() || c.isInterface()) {
                 continue;