invokeinterface on sealed interfaces

- liangchenblue at gmail.com
Sat May 22 01:50:15 UTC 2021


Greetings all,
I have heard of a myth against using interfaces, namely on how
invokeinterface is slower than invokevirtual since concrete class methods
to call, with known indices in the method table, can be found more easily
than interface methods, which always require a lookup by name.

Another myth I've heard is that JVM may decide to construct a temporary
table for interface dispatches as well, but the table would be discarded
once another class is discovered in the interface hierarchy and the
performance would slow back down.

I wonder if these two claims are right; unfortunately, I am no good at the
VM internals and can't verify them. But if they are true, I wonder if
invokeinterface calls on sealed interface methods would enjoy a performance
boost and have its performance brought closer to that of invokevirtual
calls. It seems that the sealed class design not only provides clearer
apis, but also allow the VM to better optimize code.

Best


More information about the jdk-dev mailing list