JVM是编译器还是解释器? [英] Is the JVM a compiler or an interpreter?

查看:839
本文介绍了JVM是编译器还是解释器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于JVM的基本问题:它是编译器还是解释器?



如果它是一个解释器,那么内部存在的JIT编译器呢? JVM?

如果两者都没有,那么JVM究竟是什么? (我不想要将字节代码转换为机器特定代码等的jVM的基本定义。)

解决方案

首先,让我们有一个清楚地了解以下术语



Javac 是Java编译器 - 将您的Java代码编译为字节码



JVM 是Java虚拟机 - 运行/解释/将Bytecode转换为本机代码



JIT 是即时编译器 - 将给定的字节码指令序列编译为机器代码在运行时之前本地执行它。它的主要目的是对性能进行大量优化。



现在,让我们找到你问题的答案..



1) JVM:它是编译器还是解释器? - Ans:解释器



2) JVM中存在的JIT编译器怎么样? - Ans:如果你完全阅读这个回复,你现在可能已经知道了 p>

3) JVM究竟是什么? - Ans:




  • JVM是一个驻留在RAM上的虚拟平台

  • 其组件类加载器 .class 文件加载到RAM中

  • JVM中的字节代码验证程序组件检查是否存在您的代码中的任何访问限制违规。 (这是java安全的主要原因之一)

  • 接下来,执行引擎组件将字节码转换为可执行的机器代码



希望这有助于你..


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.)

解决方案

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..

这篇关于JVM是编译器还是解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆