javac
will only do a very little optimization, if any.
The point is that the JIT compiler does most of the optimization – and it works best if it has a lot of information, some of which may be lost if javac
performed optimization too. If javac
performed some sort of loop unrolling, it would be harder for the JIT to do that itself in a general way – and it has more information about which optimizations will actually work, as it knows the target platform.