I could sure be wrong about this (or perhaps out of date). It makes sense in theory. But I can't find it in the JLS and in the bytecode I still see it calling Math.log(), calling StrictMath.log(), FWIW. I would actually believe a JIT would do something with this. But I still find myself always programming defensively so to speak.
On Thu, Apr 29, 2010 at 11:37 PM, Ted Dunning <ted.dunn...@gmail.com> wrote: >> javac definitely isn't allowed to do that kind of transformation -- it >> actually can't do much of anything. >> > > Javac and the JIT both know that log is a pure function. They also > definitely do constant sub-expression elimination and strength reduction. > Besides since logSum is a local variable there can be no side-effects. >