Archived

This topic is now archived and is closed to further replies.

Qoy

[java] Java compilers written in java?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites