Ross wrote:No. Javac may do a couple of very simple, minor optimizations of its own, but Hotspot is responsible for the meat of the optimizations.
Does javac provide optimization hints to the jvm in the class files that it generates?
If not, is this because the HotSpot jvm can analyze the class file quickly and comprehensively enough during class loading?The most significant optimizations come at runtime after a section of code has been executed a large number of times.
Or is it because including hints in the class file will increase the file size too much? Or is it some other technical reason? Or is it just because no one has gotten around to writing it yet?Most likely it's because there's no real benefit to putting any such hints in the class file. There's nothing the compiler knows that the JVM can't see by reading the file, but the JVM learns things during runtime that javac can't know. Additionally, class file parsing is s very small fraction of any program of any significant size, and if it's not, then you've got other issues that won't be solved by code optimization.