Is the JVM a compiler or an interpreter?

后端 未结 8 1024
傲寒
傲寒 2020-12-02 03:48

I have a very basic question about JVM: is it a compiler or an interpreter?

If it is an interpreter, then what about JIT compiler that exist inside the JVM?
If n

相关标签:
8条回答
  • 2020-12-02 04:42

    Like @delnan already stated in the comment section, it's neither.

    JVM is an abstract machine running Java bytecode.

    JVM has several implementations:

    • HotSpot (interpreter + JIT compiler)
    • Dalvik (interpreter + JIT compiler)
    • ART (AOT compiler + JIT compiler)
    • GCJ (AOT compiler)
    • JamVM (interpreter)

    ...and many others.

    Most of the others answers when talking about JVM refer either to HotSpot or some mixture of the above approaches to implementing the JVM.

    0 讨论(0)
  • 2020-12-02 04:50

    It is both. It starts by interpreting bytecode and can (should it decide it is worth it) then compile that bytecode to native machine code.

    0 讨论(0)
提交回复
热议问题