Take the 2-minute tour ×  Recently I bumped into a situation
where a static code analysis tool (PMD) complainted about a
switch statement that had too few branches. It suggested turning
it into an if statement, that I did not wanted to do because I
knew that soon more cases will be added. But I wondered if the
javac performs such an optimization or not. I decompiled the
code using JAD but it showed still a switch. Is it possible that
this is optimized runtime by the JIT?  Update: Please do not be
misleaded by the context of my question. I'm not asking about
PMD, I'm not asking about the need for micro-optimisation, etc.
The question is clearly only this: does the current (Oracle
1.6.x) JVM implementation contain a JIT that deals with switches
with too few branches or not.  share|improve this question I
thought PMD has nothing to do with JIT? –  gefei Sep 12 '12 at
11:30 Of course it doesn't. The question was not that.. –  jabal
Sep 12 '12 at 11:51 add comment  4 Answers  up vote 1 down vote
accepted  If you c