The Java Programming Language Compiler, javac (original) (raw)
The Java programming language compiler, javac
, reads source files written in the Java programming language, and compiles them into bytecode class files. Optionally, the compiler can also process annotations found in source and class files using the Pluggable Annotation Processing API. The compiler is a command line tool but can also be invoked using the Java Compiler API. The compiler accepts source code defined by the Java Language Specification (JLS) and produces class files defined by the Java Virtual Machine Specification (JVMS).
API Specification
This lists the APIs introduced in the javac
tool:
- **javax.annotation.processing**- Annotation processing
- **javax.lang.model**- Language model used in annotation processing and Compiler Tree API
- **javax.lang.model.element**- Language elements
- **javax.lang.model.type**- Types
- **javax.lang.model.util**- Language model utilities
- javax.tools - Java Compiler API
- com.sun.source.* - Provides read-only acccess to abstract syntax trees that thejavac tool uses
Enhancements in Java SE 8
- The javac tool now provides the ability to generate native headers as needed. This removes the need to run thejavah tool as a separate step in the build pipeline. The feature is enabled in javac by using the new -hoption, which is used to specify a directory in which the header files should be written. Header files will be generated for any class which has either native methods, or constant fields annotated with a new annotation of typejava.lang.annotation.Native.
- The javac tool now has support for checking the content of javadoc comments for issues which could lead to various problems, such as invalid HTML or accessibility issues, in the files that are generated when javadoc is run. The feature is enabled by the new -Xdoclint option. For more details, see the output from running "javac -X". This feature is also available in javadoc, and enabled there by default.
Enhancements in Java SE 7 Update 2
Area: Compiler
Synopsis: The Java 7 compiler used to erroneously accept the diamond operator in array initializer expressions. For example, the following code, which was previously accepted, is now rightly rejected:
class Foo {}
class Test { Foo[] fooArr = new Foo<>[]{ }; //error }
See 7057297.
Area: Compiler
Synopsis: The Java 7 compiler erroneously accepted the following program due to a bug in the most specific algorithm implementation:
import java.util.*;
interface A {List getList();} interface B {ArrayList getList();} interface AB extends A, B {}
class Test { void test(AB ab) { Number n = ab.getList().get(1); } }
This program used to fail in JDK 6. A fix has been provided in Java SE 7u2 to rightly reject this program. See 7062745.
More Information
For more information on javac
tool, visit the following links:
- The javac Home Page: It lists several API implementations of javac
- javac Manual page [ Solaris, Linux, or Mac OS X |Microsoft Windows ]
- Java Language Specification and Java Virtual Machine Specification