Java compiler
Encyclopedia
A Java compiler is a compiler
for the Java programming language
. The most common form of output from a Java compiler is Java class files
containing platform-neutral Java bytecode
. There exist also compilers emitting optimized native machine code
for a particular hardware/operating system
combination.
Most Java-to-bytecode compilers, Jikes
being a well known exception, do virtually no optimization
, leaving this until run time to be done by the JRE.
The Java Virtual Machine
(JVM) loads the class files and either interprets
the bytecode
or just-in-time
compiles it to machine code
and then possibly optimizes it using dynamic compilation
.
The very first Java compiler developed by Sun Microsystems was written in C using some libraries from C++.
s:
tries to reverse the process of compiling, that is it tries to decompile Java bytecode files (*.class) back to Java source files (*.java).
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
for the Java programming language
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
. The most common form of output from a Java compiler is Java class files
Class (file format)
In the Java programming language, source files are compiled into machine-readable class files which have a .class extension. Since Java is a platform-independent language, source code is compiled into an output file known as bytecode, which it stores in a .class file. If a source file has more...
containing platform-neutral Java bytecode
Java bytecode
Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode opcode is one byte in length, although some require parameters, resulting in some multi-byte instructions. Not all of the possible 256 opcodes are used. 51 are reserved for future use...
. There exist also compilers emitting optimized native machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...
for a particular hardware/operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
combination.
Most Java-to-bytecode compilers, Jikes
Jikes
Jikes is an open source Java compiler written in C++. It is no longer being updated.The original version was developed by David L. "Dave" Shields and Philippe Charles at IBM but was quickly transformed into an open source project contributed to by an active community of developers. Initially hosted...
being a well known exception, do virtually no optimization
Optimization (computer science)
In computer science, program optimization or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources...
, leaving this until run time to be done by the JRE.
The Java Virtual Machine
Java Virtual Machine
A Java virtual machine is a virtual machine capable of executing Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems stated that there are over 4.5 billion JVM-enabled devices.-Overview:...
(JVM) loads the class files and either interprets
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...
the bytecode
Bytecode
Bytecode, also known as p-code , is a term which has been used to denote various forms of instruction sets designed for efficient execution by a software interpreter as well as being suitable for further compilation into machine code...
or just-in-time
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...
compiles it to machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...
and then possibly optimizes it using dynamic compilation
Dynamic compilation
Dynamic compilation is a process used by some programming language implementations to gain performance during program execution. Although the technique originated in the Self programming language, the best-known language that uses this technique is Java...
.
The very first Java compiler developed by Sun Microsystems was written in C using some libraries from C++.
Major Java compilers
As of 2010, the following are major Java compilerCompiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
s:
- javacJavacjavac is the primary Java compiler, included in the Java Development Kit from Oracle Corporation.The compiler accepts source code conforming to the Java language specification and produces bytecode conforming to the Java Virtual Machine Specification .javac is itself written in Java...
, included in JDKJava Development KitThe Java Development Kit is an Oracle Corporation product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java SDK. On 17 November 2006, Sun announced that it would be released under the GNU General Public License , thus making it free software...
from Sun MicrosystemsSun MicrosystemsSun Microsystems, Inc. was a company that sold :computers, computer components, :computer software, and :information technology services. Sun was founded on February 24, 1982...
, open-sourced since 13 November 2006. - GCJ, a part of gccGNU Compiler CollectionThe GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
which compiles CC (programming language)C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
, FortranFortranFortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...
, Pascal and other programming languageProgramming languageA programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
s besides Java. It can also generate native code using the back-end of gcc. - ECJ, the Eclipse Compiler for Java, is an open source incremental compilerIncremental compilerThe term incremental compiler may refer to two different types of compiler.-Imperative programming:In imperative programming and software development, an incremental compiler is one that when invoked, takes only the changes of a known set of source files and updates any corresponding output files ...
used by the EclipseEclipse (software)Eclipse is a multi-language software development environment comprising an integrated development environment and an extensible plug-in system...
project.
Java decompilers
A Java decompilerDecompiler
A decompiler is the name given to a computer program that performs, as far as possible, the reverse operation to that of a compiler. That is, it translates a file containing information at a relatively low level of abstraction into a form having a higher level of abstraction...
tries to reverse the process of compiling, that is it tries to decompile Java bytecode files (*.class) back to Java source files (*.java).
- DJ Java Decompiler http://www.neshkov.com/ (Uses JAD) 10 use trial version
- JADJAD (JAva Decompiler)Jad is a currently unmaintained decompiler for the Java programming language.Jad provides a command-line user interface to extract source code from class files.The most popular GUI for Jad is...
, written in C++C++C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
, free for non-commercial use. - JD http://java.decompiler.free.fr/, younger project, includes GUI, optional Eclipse-plugin.
- JODE http://jode.sourceforge.net/, decompiler and optimizer, open-source.
- MochaMocha (decompiler)Mocha is a Java decompiler, which allows programmers to translate a program's bytecode into source code.A beta version of Mocha was released in 1996, by Dutch developer Hanpeter van Vliet, alongside an obfuscator named Crema. A controversy erupted and he temporarily withdrew Mocha from public...
, one of the first decompilers for Java.
External links
- Sun's OpenJDK javac page
- Jikes homepage
- JSR 199 Java Compiler API Java Specification Request for invoking the Java compiler from a Java program