src/hotspot/share/oops/klassVtable.cpp
changeset 48819 ee513596f3ee
parent 48608 1dab70e20292
parent 48794 ea0d0781c63c
child 49359 59f6547e151f
--- a/src/hotspot/share/oops/klassVtable.cpp	Tue Jan 30 16:26:40 2018 +0100
+++ b/src/hotspot/share/oops/klassVtable.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1200,7 +1200,6 @@
   Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
   int nof_methods = methods->length();
   HandleMark hm;
-  assert(nof_methods > 0, "at least one method must exist for interface to be in vtable");
   Handle interface_loader (THREAD, InstanceKlass::cast(interf)->class_loader());
 
   int ime_count = method_count_for_interface(interf);
@@ -1369,8 +1368,10 @@
       }
     }
 
-    // Only count interfaces with at least one method
-    if (method_count > 0) {
+    // Visit all interfaces which either have any methods or can participate in receiver type check.
+    // We do not bother to count methods in transitive interfaces, although that would allow us to skip
+    // this step in the rare case of a zero-method interface extending another zero-method interface.
+    if (method_count > 0 || InstanceKlass::cast(intf)->transitive_interfaces()->length() > 0) {
       blk->doit(intf, method_count);
     }
   }