tags:

views:

83

answers:

3

I'm confused with JIT compiler,

  1. What is JIT compiler?
  2. JIT compiler compiles byte codes before each execution or each time JVM loads?
+1  A: 

The JIT compiler is a specialized compiler that will watch Java bye code run and compile it into native instructions if necessary.

If the JIT determines that a part of your code is running very frequently, or that compiling it to native code will significantly increase performance, it will do so.

JIT compilation is completely optional, and the standard implementation of Java allows you to turn it off. However, there is really no reason to turn it off.

jjnguy
Does it mean that the JIT compilation is an optional?
Thomman
Yes, it is optional in the sense that you can turn it off; however, it is turned on by default (and that's a good thing).
Edwin Buck
On Sun's implementation of Java you can turn JIT compilation off by using the command line option `-Xint` but normally you would not do that.
Jesper
+3  A: 

JIT stands for "Just In Time". It's a compiler that translates Java bytecode to native machine code as your program runs.

Sun's JIT does not compile all your bytecode up front each time you run a Java program; it contains some very sophisticated logic to decide when to compile parts of the bytecode, one of the criteria it uses is how often the code is executed.

See Just-in-time compilation and HotSpot (Wikipedia) for more details.

Jesper
A: 

The JIT compiler was an external just-in-time compiler that shipped with Java 1.1. The term is now obsolete. Java ships with a 'HotSpot' JVM that has compilation built in to it.

EJP