Hi,
Is JVM a compiler or an interpreter?
-Thanks & Regards,
Hamsa
The JVM used to be just an interpreter and in a lot of implementations just
'green' threads were implemented (they blocked when an OS call blocked).
After a lot of complaints had come in about the lack of speed Sun came up
with 'hotspot' compilation which is JIT (Just In Time) compilation plus a watch-
dog that determined *what* code to compile and when in order to speed up
the execution of the virtual machine code.
Nowadays the JVM even preloads a lot of core classes (compiled to machine
code) such as String, Number, Integer etc. There still is an interpreter on board
but the hotspot mechanism is so 'aggressive' nowadays that most (if not all)
of the code is compiled to actual machine code before it could run in interpreted
mode.
So the JVM is a bit of both but it became more of a compiler nowadays. Note that
it doesn't compile a high level human readable language (that's the job for javac)
but it translates virtual machine code (the Java byte code) to native machine code.
kind regards,
Jos