Possible Duplicate:
Why doesn't the JVM cache JIT compiled code?
I understand that JIT compilation is compilation to native code using hotspot mechanisms, which can be very very fast as it is optimization to the OS, Hardwards, etc.
My question is, why does Java not store that JIT complied code somewhere in file and use the same for future purposes? This can reduce the 'initial warm-up' time as well.
Please let me know what I am missing here.
To add to my question: Why does not Java complie the complete code to native and use that always(for a specific JVM,OS, platform)? Why JIT?
If I remember correctly, caching and sharing of JIT-compiled code has been tried, and found to be not a good idea.
On the one hand, a modern HotSpot JIT compiler generates and optimizes code in the context of the current CPU model, and the usage patterns of the current execution. If it were to cache compiled code, then there is a good chance that the code would not be optimal.
On the other hand, there are apparently a variety of tricking technical problems. For instance, the cached code becomes a potential security hole, For instance, the code area needs to be writeable by all applications / users that share it. But that means that one user could potentially interfere with the running of another user's applications.