Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

java - Is the JVM a compiler or an interpreter?

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 neither, then what exactly is the JVM? (I dont want the basic definition of jVM of converting byte code to machine specific code etc.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First, let's have a clear idea of the following terms

Javac is Java Compiler -- Compiles your Java code into Bytecode

JVM is Java Virtual Machine -- Runs/ Interprets/ translates Bytecode into Native Machine Code

JIT is Just In Time Compiler -- Compiles the given bytecode instruction sequence to machine code at runtime before executing it natively. It's main purpose is to do heavy optimizations in performance.

So now, Let's find answers to your questions..

1)JVM: is it a compiler or an interpreter? -- Ans: Interpreter

2)what about JIT compiler that exist inside the JVM? -- Ans: If you read this reply completly, you probably know it now

3)what exactly is the JVM? -- Ans:

  • JVM is a virtual platform that resides on your RAM
  • Its component, Class loader loads the .class file into the RAM
  • The Byte code Verifier component in JVM checks if there are any access restriction violations in your code. (This is one of the principle reasons why java is secure)
  • Next, the Execution Engine component converts the Bytecode into executable machine code

Hope this helped you..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...