3 ms·
While the actual implementation method that will be invoked is unknown, in a statically typed language the base class/interface and the method signature are kno
by allertonm 18y ago
While the actual implementation method that will be invoked is unknown, in a statically typed language the base class/interface and the method signature are known. In Java/Scala classes the types of the arguments are baked into the method names used by the bytecode so this is important information from a performance point-of-view.
Looking up this information at run-time (via reflection) is slow, but dynamic languages on the JVM have have been forced to do that when calling into Java classes from the dynamic language - which is the starting point of the original article.
Scala is not affected by this because it is not a dynamic language and the Scala compiler has the exact same information that the Java compiler does when it compiles a call from Scala to Java.