Documentation Contents

The Java™ Programming Language Compiler, javac

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

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<X> {}

class Test {
    Foo<String>[] 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<Number> 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


Oracle and/or its affiliates Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.
Contact Us