In which language are the Java compiler and JVM wr

2019-01-05 07:22发布

In which languages are the Java compiler (javac), the virtual machine (JVM) and the java starter written?

标签: java jvm javac
9条回答
我想做一个坏孩纸
2楼-- · 2019-01-05 07:44

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.

We can imagine how the Java compiler was written in Java like this:

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.

查看更多
\"骚年 ilove
3楼-- · 2019-01-05 07:45

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.

  • 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. For example, the original IBM JVM was written in 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++.

  • I believe that the Java compiler provided by Sun is also written in Java. (Although again, there are multiple compilers out there)

查看更多
我只想做你的唯一
4楼-- · 2019-01-05 07:45

On most operating systems, JVMs are written in ISO C++. I doubt ANSI C is used, as it's an entirely different language that is quite antiquated nowadays.

查看更多
干净又极端
5楼-- · 2019-01-05 07:50

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

查看更多
乱世女痞
6楼-- · 2019-01-05 07:55

From Java Docs

The compiler is written in Java and the runtime is written in ANSI C

查看更多
放荡不羁爱自由
7楼-- · 2019-01-05 07:57

This link should answer your question

It seems the compiler is now written in Java, but the runtime is written in ANSI C

查看更多
登录 后发表回答