Java FAQ: Top Questions
61. What is Just-In-Time (JIT) compilation in Java?
Just-In-Time (JIT) compilation is a JVM technique that compiles Java bytecode to native machine code at runtime, improving performance by optimizing frequently executed code.
Key points:
- Interpreted vs. Compiled: Initially, bytecode is interpreted; hot methods are compiled to native code.
- HotSpot JVM: Uses two JIT compilers: C1 (client, fast startup) and C2 (server, aggressive optimizations).
- Optimizations: Inlining, loop unrolling, dead code elimination, escape analysis.
-
Thresholds:
Controlled by
-XX:CompileThreshold
for compilation triggers. - Use Case: Enhances runtime performance of long-running applications.