Java编译器(javac)、虚拟机(JVM)和Java启动器是用哪种语言编写的?


当前回答

实际上,Oracle JVM是用c++编写的,而不是C。

看看HotSpot JVM代码:http://openjdk.java.net/groups/hotspot/

其他回答

原则上几乎任何事情,通常C

来自Java文档

编译器是用Java编写的,运行时是用ANSI C编写的

When Java was 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 Bootstrapping, Mostly it is used in Compiler Development, Bootstrapping is 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 language 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 runtime. Usually, JVM interprets the byte code into Machine code.

(有关更多信息,您可以查看此链接:https://docs.oracle.com/javase/specs/jvms/se7/html/)

实际上,Oracle JVM是用c++编写的,而不是C。

看看HotSpot JVM代码:http://openjdk.java.net/groups/hotspot/

第一个Java编译器是由Sun Microsystems开发的,用C语言编写,使用了c++中的一些库。今天,Java编译器是用Java编写的,而JRE是用C编写的。

我们可以想象一下Java编译器是如何用Java编写的:

Java编译器是作为Java程序编写的,然后用C语言编写的Java编译器(第一个Java编译器)进行编译。因此,我们可以使用新编译的Java编译器(用Java编写)来编译Java程序。