3 ms·
Except that a smart runtime can actually work with the assumption that only one implementation of a class will be used, and inline what would otherwise be virtu
by dzaima 5y ago
Except that a smart runtime can actually work with the assumption that only one implementation of a class will be used, and inline what would otherwise be virtual methods. And, as far as I know, the JVM definitely does this, and at multiple levels too - if there's only one implementation of an interface, it can just assume that everything's static and inlineable (at the cost of deoptimizations if that turns out to be false later). If not, it can still decide to inline, and just check the type beforehand.