Is the Java Bootstrapped Compiler?

Is the Java Bootstrapped Compiler?

How was the first java compiler written if it was loaded?

+4
source share
2 answers

This is an interesting question. Oracle's current javac compiler, which is only one compiler of many (1), is actually written in Java, which means that yes, you might think it was loaded, assuming your definition means "was bootstrapped so that it can now compile yourself (2) .

The virtual machine itself is written primarily in C ++ from memory, so when the compiler loads, the C ++ compiler is required to create the JRE.


(1) GCJ is another one, and it seems to be written in C, so it depends on who you should be contacting.

(2) The only word "bootstapped" in your question can be adopted in several ways. If your definition of "bootstrapped" means "must be loaded in order to get a working compiler", then the answer will be no.


As for how the first Java compiler was written before the start of the download, it remains lost in the fog of time (or the minds of Gosling and others).

Given that a compiler can be written relatively easily without any fantastic OO concepts, I assume that they just wrote the first (or several) in C or C ++.

This is similar to this entry with the Wayback Machine :

The team’s efforts began with the development of a new object-oriented programming language, which Gosling called Oak after the tree outside the window. Based on C ++, the language was exhausted to a minimum to be compatible with the limited space offered by handheld device chips, and was designed to allow programmers to more easily support dynamic, mutable hardware.

and then:

Arthur van Hoff wrote the Oak compiler entirely in Oak, not C. Naughton, and Jonathan Payne built a browser prepared in the form of an oak called "WebRunner". The first applet - the Duke, with his back to his parents over the Internet - was born.

Also, from Patrick Naughton’s Epilogue in his book, Java Reference (boldly):

Now that we had a recording plan to send Oak to its original form on the net, everything became much more productive. We began to focus on fixing all the free ends in the language. Jonathan Payne worked on translator optimization. Arthur van Hoff rewrote the compiler in the oak itself, replacing the C version that James wrote. It was a good environment test, as this compiler was the largest single Oak program ever written. Many burned out engineers used this time as Sun's paid vacation, but for the most part the core team ignored them and got back to work.

So, it looks like the original version of the Java (Oak) compiler was written in C and then loaded from there.

+6
source

According to http://openjdk.java.net/groups/compiler/ :

Note that the code for the native launcher for javac is shared with all other JDK tools and lives in the JDK repository. If you just download and create the langtools repository, you will get a jar executable that you can invoke directly with java or with the simple shell script provided.

Therefore, the compiler is written in Java. So yes, it loads in the sense that you need to compile it with an earlier version of the Java compiler.

0
source

Source: https://habr.com/ru/post/1395708/


All Articles