Java 编译器和 JVM 是用哪种语言编写的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1220914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In which language are the Java compiler and JVM written?
提问by Rahul Garg
In which languages are the Java compiler(javac
), the virtual machine (JVM) and the java
starter written?
Java编译器( javac
)、虚拟机 (JVM) 和java
启动器是用哪些语言编写的?
采纳答案by oxbow_lakes
The precise phrasing of the question is slightly misleading: it is not "the JVM"or "the compiler"as there are multiple JVM vendors(jrockit is one, IBM another) and multiple compilersout there.
这个问题的准确措辞有点误导:它不是“JVM”或“编译器”,因为有多个 JVM 供应商(jrockit 是一个,IBM 是另一个)和多个编译器。
The Sun JVM iswritten in
C
, although this need not be the case - the JVM as it runs on your machine is a platform-dependentexecutable and hence couldhave been originally written in any language. For example, the original IBM JVM was written in SmalltalkThe Java libraries (
java.lang
,java.util
etc, often referred to as the Java API) are themselves written in Java, although methods marked asnative
will have been written inC
orC++
.I believe that the Java compiler provided by Sun is also written in Java. (Although again, there are multiple compilers out there)
太阳JVM是写在
C
,虽然这不是必须的情况下-因为它运行在您的机器上是JVM的一个平台相关的可执行文件,因此可能最初被用任何语言编写。例如,最初的 IBM JVM 是用Smalltalk编写的Java库(
java.lang
,java.util
等等,通常被称为了Java API)本身是用Java编写的,虽然标注为方法native
将已经写在C
或C++
。相信Sun提供的Java编译器也是用Java编写的。(尽管同样,那里有多个编译器)
回答by djna
In principle almost anything, usually C
原则上几乎任何东西,通常是 C
回答by Sev
回答by micmoo
回答by Sam Harwell
Jikes RVM, a self-hosting JVM used extensively for research purposes is written in Java. It's not the one people run on their desktops, but it's way up there on my list of "now let's show off the general power of the language."
Jikes RVM是一种广泛用于研究目的的自托管 JVM,它是用 Java 编写的。它不是人们在桌面上运行的那种,但它在我的“现在让我们炫耀语言的强大力量”的列表中名列前茅。
回答by Michael Foukarakis
Supposing you're talking about the Hotspot JVM, which is iirc provided by Sun, it is written in C++. For more info on the various virtual machines for Java, you can check this link. javac, like most Java compilers, is written in Java.
假设您在谈论 Hotspot JVM,它是 Sun 提供的 iirc,它是用 C++ 编写的。有关 Java 的各种虚拟机的更多信息,您可以查看此链接。 javac与大多数 Java 编译器一样,是用 Java 编写的。
回答by UrbenLegend
Actually the Oracle JVM is written in C++, not C.
实际上,Oracle JVM 是用 C++ 编写的,而不是 C。
Take a look at the HotSpot JVM code here: http://openjdk.java.net/groups/hotspot/
在此处查看 HotSpot JVM 代码:http: //openjdk.java.net/groups/hotspot/
回答by shrinath
The very first Java compiler was developed by Sun Microsystems and was written in C using some libraries from C++. Today, the Java compiler is written in Java, while the JRE is written in C.
第一个 Java 编译器是由 Sun Microsystems 开发的,是使用 C++ 中的一些库用 C 编写的。今天,Java 编译器是用 Java 编写的,而 JRE 是用 C 编写的。
We can imagine how the Java compiler was written in Java like this:
我们可以想象 Java 编译器是如何用 Java 编写的:
The Java compiler is written as a Java program and then compiled with the Java compiler written in C(the first Java compiler). Thus we can use the newly compiled Java compiler(written in Java) to compile Java programs.
Java 编译器是作为 Java 程序编写的,然后用 C 语言编写的 Java 编译器(第一个 Java 编译器)进行编译。这样我们就可以使用新编译的Java编译器(用Java编写)来编译Java程序。
回答by Trishant Saxena
- When Java is introduced by Sun Microsystem, the java compiler was written in C using some libraries from C++.
- As There is a concept in Compiler Design called Bootstapping, Mostly it is used in Compiler Development, Bootstrappingis the process of writing a compiler(Or Assembler) In the source programming language which it is intended to compile. It is used to produce a self-hosting compiler. The development of compilers for new Programming languages first developed in an existing langauge and then rewritten in the new language and compiled by itself. That's why today, Java compiler is written in Java itself.
- Java Virtual Machine:Java virtual machine is an abstract machine. Like a real computing machine, It has an instruction set and manipulates various memory areas of run time.Usually JVM interprets the byte code into Machine code.
- 当 Sun Microsystem 引入 Java 时,Java 编译器是使用 C++ 中的一些库用 C 编写的。
- 由于编译器设计中有一个概念称为 Bootstapping,它主要用于编译器开发,Bootstrapping是在要编译的源编程语言中编写编译器(或汇编器)的过程。它用于生成自托管编译器。新编程语言编译器的开发首先用现有语言开发,然后用新语言重写并自行编译。 这就是为什么今天,Java 编译器是用 Java 本身编写的。
- Java虚拟机:Java虚拟机是一个抽象的机器。就像一台真正的计算机器,它有一个指令集,操作运行时的各种内存区域。通常JVM将字节码解释成机器码。
(For More Information You can check this link : https://docs.oracle.com/javase/specs/jvms/se7/html/)
(有关更多信息,您可以查看此链接:https: //docs.oracle.com/javase/specs/jvms/se7/html/)