by willtim · 7y ago · 0 comments
Strings in switch Statements:
https://docs.oracle.com/javase/7/docs/technotes/guides/langu...
Supporting a switch on static final references would be a good first step.
I did say vtable dispatch was efficient, but I might not want to split my logic across classes. A chain of if-else is a linear scan and not efficient. Switch in its current form is too limited.
It is well known that Java has no value types (there is a JSR). Even for a primitive type, the collection libraries need to box all values in order to abstract the element type. Every HFT user on Wall Street has had to write their own collections library using custom code generation to work around this.
The JVM has complete knowledge of the class hierarchy. If a method has not been replaced in a subclass then no vtable entry has to be generated and the JVM just uses a static call.