Engineering Full Stack Apps with Java and JavaScript
Java is not purely a traditional compiled or interpreted language, but tries to come in between them.
In Java, source code is compiled into an optimized platform independent binary bytecode, and then this byte code is executed by Java’s interpreter. Java’s interpreter, JVM, execute an optimized form of source code, not the high level source code itself. So the execution will be clearly faster than a regular interpreter that interprets the source code.
Java can compile the bytecode again to platform specific binary with additional optimizations during execution and the reuse this compiled form when it is needed again during hte execution. This is called Just-In-Time compilation.
There are multiple implementations of JVM. Oracle itself provides open source and commercial JVM versions. IBM provides its own JVM along with its products.
Oracle’s standard JVM implementation (that we download from oracle downloads page) is known as Hotspot JVM.
Hotspots are sections of code that are executed more than other sections of code. It would not be worth to compile and execute a section of code which is executed only once or very less times; instead it would be better to interpret the bytecode directly without compiling in those cases. Compiling a frequently executing section of code (hotspot) will be worth as the extra CPU cycle time taken for compilation can be overcome during subsequent runs. Also, more the JVM executes sections of code it can figure out more optimizations that can be made.
Comments
in what cases jit will be
in what cases jit will be done
JIT is enabled by default and
JIT is enabled by default and it improves the permofmance by compiling bytecode into native machine code at runtime and JVM calls the compiled code directly