[java] Java compilers written in java?

Started by
8 comments, last by Qoy 20 years, 8 months ago
Does anyone know of any free (open source) java compilers written in Java?
Advertisement
As far as I know, they don''t exist. That would probably be a bit slow for compilation, anyway.

The Artist Formerly Known as CmndrM

http://chaos.webhop.org
Well, javac, the Sun Java compiler is written in java, so they perform well enough Unfortunately, it''s not open source (or it doesn''t seem to be at least).
It is? I always thought it was built in C or C++...

The Artist Formerly Known as CmndrM

http://chaos.webhop.org
It''s definitely written in Java. You can find the .class files in your JDK directory under lib in tools.jar (com.sun.tools.javac package).

One interesting effect of this is that the compiler will run unmodified on any platform for which a VM is implemented.
The source code for the JDK is available, I''ll bet javac is in there. Despite the source code being available it''s not exactly "open source", it''s under a very strict license.

All of the java tools provided in the standard jdk are written in Java. Why wouldn''t Sun themselves take advantage of their own language? Write javac once, and well, run it anywhere
Are you sure you mean compiler and not IDE? A compiler written entirely in Java is possible, but it would then rely heavily on the JRE, which uses native calls to do everything.

And since javac is an exe, and not a .class file, I would guess that it''s written natively for each OS. That''s also why Apple writes their own JDK and JRE for Macs. And they do keep it to Sun''s specs.
nickwinters:
Yes, the java *compiler* is written in Java. The exe is just a frontend that launches it. And of course it relies on the JRE to run-- but all Java software does

tortoise:
For my current project, licensing the code might be an option, but I haven''t been able to find any information about it. Do you know where I can?
If I remember correctly, the top of every source file from the JDK details the license and where to go for more info/contacts, etc.

And yes, javac, as well as jar, javah, javap, javadoc, etc are all written in java. Most use java''s reflection capabilities to do their job.

jikes, IBM''s java compiler, is written in C++. Which is why it''s so blazing fast.
This article http://developer.java.sun.com/developer/JDCTechTips/2003/tt0722.html#2 might have what you are looking for.

You have to be a member to read it, but it is free to join anyway.

[EDIT]ps. Here is a quote from the article that will answer one debate here.
quote:
The command line-based javac compiler is simply a wrapper to the com.sun.tools.javac.Main class. Using the class's static compile method, you can pass (in a String[]) the name of one or more files to compile, and you don't need to use the command line for the compilation.


First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

[edited by - CaptainJester on August 1, 2003 10:52:47 PM]
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]

This topic is closed to new replies.

Advertisement