1. 3

Single superclass inheritance enables simple and efficient table-driven virtual method dispatcj. However, virtual method table dispatch does not handle multiple inheritance and interfaces. This complication has led to a widespread misimpression that interface method dispatch is inherently inefficient. This paper argues that with proper implementation techniques, Java interfaces need not be a source of significant performance degradation.


  2. 1

    Tangentially related is an amazing optimization for virtual calls in Android ART 8.0 which devirtualizes calls if only one implementation exists (and then possible inlines it!). I’m unsure if OpenJDK has a similar optimization, but the space for optimizing JVM implementations is still very open.

    1. 2

      Single implementation devirtualisation has been standard practice for all Java JITs for all time - because of the “everything is virtual by default” decision at the core of the language.

      Even .NET does it despite virtual dispatch not being a default in the primary languages as there are enough high frequency calls that are technically overridable but are not overridden in practice.