[英]In which language are the Java compiler and JVM written?
Java编译器( javac
)、虚拟机 (JVM) 和java
starter 是用哪些语言编写的?
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 compilers out there.这个问题的准确措辞有点误导:它不是“JVM”或“编译器”,因为有多个 JVM 供应商(jrockit 是一个,IBM 是另一个)和多个编译器。
The Sun JVM is written in C
, although this need not be the case - the JVM as it runs on your machine is a platform-dependent executable and hence could have been originally written in any language.太阳JVM是写在
C
,虽然这不是必须的情况下-因为它运行在您的机器上是依赖于平台的可执行文件,因此本来最初写在任何语言的JVM。 For example, the original IBM JVM was written in Smalltalk例如,最初的 IBM JVM 是用Smalltalk编写的
The Java libraries ( java.lang
, java.util
etc, often referred to as the Java API ) are themselves written in Java, although methods marked as native
will have been written in C
or C++
. Java 库(
java.lang
、 java.util
等,通常称为Java API )本身是用 Java 编写的,尽管标记为native
方法将是用C
或C++
编写的。
I believe that the Java compiler provided by Sun is also written in Java.相信Sun提供的Java编译器也是用Java编写的。 (Although again, there are multiple compilers out there)
(尽管同样,那里有多个编译器)
The very first Java compiler was developed by Sun Microsystems and was written in C using some libraries from C++.第一个 Java 编译器是由 Sun Microsystems 开发的,是使用 C++ 中的一些库用 C 编写的。 Today, the Java compiler is written in Java, while the JRE is written in 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). Java 编译器是作为 Java 程序编写的,然后用 C 语言编写的 Java 编译器(第一个 Java 编译器)进行编译。 Thus we can use the newly compiled Java compiler(written in Java) to compile Java programs.
这样我们就可以使用新编译的Java编译器(用Java编写)来编译Java程序。
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/
原则上几乎任何东西,通常是 C
Jikes RVM , a self-hosting JVM used extensively for research purposes is written in Java. Jikes RVM是一种广泛用于研究目的的自托管 JVM,它是用 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."
它不是人们在他们的桌面上运行的那个,但它在我的“现在让我们炫耀该语言的一般力量”的列表中名列前茅。
Supposing you're talking about the Hotspot JVM, which is iirc provided by Sun, it is written in C++.假设您在谈论 Hotspot JVM,它是 Sun 提供的 iirc,它是用 C++ 编写的。 For more info on the various virtual machines for Java, you can check this link .
有关 Java 的各种虚拟机的更多信息,您可以查看此链接。 javac , like most Java compilers, is written in Java.
javac与大多数 Java 编译器一样,是用 Java 编写的。
(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/ )
On most operating systems, JVMs are written in ISO C++. 在大多数操作系统上,JVM是用ISO C ++编写的。 I doubt ANSI C is used, as it's an entirely different language that is quite antiquated nowadays.
我怀疑是否使用了ANSI C,因为它是一种完全不同的语言,现在相当陈旧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.