The best way to write JIT-friendly code is to write simple, simple code because it is what JIT is looking for and knows how to optimize. No tricks!
Different JVMs also have different JITs, so to be sure that your code works well with all of them, you should not rely on any of them.
A common way to improve JIT performance is through the external configuration of the JVM. Since most JVMs today know how to directly access the inline code method, most performance results come from tuning the garbage collector. Here, a lot of effort is used to avoid having to stop your program during collection, and you can tune your knowledge a bit about how the basic equipment is configured and what works better than others. But not Java code, it should be simple and simple.
source share