I was wondering, why does Math.sin(double)
delegate to StrictMath.sin(double)
when I\'ve found the problem in a Reddit thread. The mentioned code f
Why does Math.sin() delegate to StrictMath.sin()?
The JIT compiler should be able to inline the StrictMath.sin(a)
call. So there's little point creating an extra native
method for the Math.sin()
case ... and adding extra JIT compiler smarts to optimize the calling sequence, etcetera.
In the light of that, your objection really boils down to an "elegance" issue. But the "pragmatic" viewpoint is more persuasive:
Fewer native calls makes the JVM core and JIT easier to maintain, less fragile, etcetera.
If it ain't broken, don't fix it.
At least, that's how I imagine how the Java team would view this.