Is java a Just In Time compiler (JIT) or is java compiled by the programmer with javac. If both, whats the benefit of each?
1 Answer
Java is compiled into Java Bytecodes. Those bytecodes are then interpreted by the Java Virtual Machine at runtime. So technically neither.
7 Comments
sepp2k
JIT compilation != interpretation. The HotSpot JVM interprets bytecode at first and then JIT-compiles methods that are called a lot. Previous JVMs only interpreted the bytecode. In that case there'd be no JIT compilation going on.
ArthuruhtrA
Is the difference that the bytecode can't be modified while running?
sepp2k
The difference is that JIT compilation translates the bytecode to machine code (i.e. it compiles it) and then runs the machine code, whereas interpretation simply executes the bytecode without compiling anything.
ArthuruhtrA
How can it execute without translating it to something the processor can understand?
sepp2k
Something like
if(instruction.isAdd()) { memory[instruction.target()] += instruction.argument(); } else if ... |