Posted by samuelto
on February 19, 2007 at 12:41 PM PST
What optimizations does hotspot have for switch statement? For example, if I have a switch with many cases (all the case values are constants):
protected Object invokeGetterForIndex(int index) throws Exception
.. .. ..
Does hotspot evaluate it as a big if-else statement or are there some optimizations that will be done? I found an article describing some potential optimizations (http://www.research.ibm.com/journal/rd/485/suganuma.html ), but wasn't sure if whether hotspot does any of them or whether it works only if I'm returning constant values (in this case I need to call a method for each case).