/* JavaCompiler.java -- Programmatic interface for a compiler. Copyright (C) 2012 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.tools; import java.io.Writer; import java.nio.charset.Charset; import java.util.Locale; import java.util.concurrent.Callable; import javax.annotation.processing.Processor; /** *
* Provides a programmatic interface to a compiler for the Java * programming language. The compiler relies on two services; * a diagnostic listener for producing textual output including * warnings or errors from the code, and a file manager for providing * access to the files to be compiled and the output location. * More detail on these services and various helper classes related * to them is provided below. The classes {@link DiagnosticListener}, * {@link JavaFileManager}, {@link FileObject} and {@link JavaFileObject} * provide the service provider interface for these services and are not * intended for user consumption.
*Compilers implementing {@link JavaCompiler} must conform to the Java * Language Specification and produce class files conforming to the * Java Virtual Machine Specification. In addition, those compilers * which claim to support {@link SourceVersion#RELEASE_6} or later * must support annotation processing.
*Where possible, the compiler provides diagnostic output to * a {@link DiagnosticListener} if provided. If a listener is * not provided, diagnostics are instead written to the default * output ({@code{System.err} by default). This may also happen * where the diagnostics are inappropriate for a {@link Diagnostic} * object. The class {@link DiagnosticCollector} provides a means * collate together multiple {@link Diagnostic}s in a list.
*A compiler tool has an associated standard file manager which * is native to it. An instance of it can be obtained by calling * {@link #getStandardFileManager(DiagnosticListener,Locale,Charset)} * and this is automatically called if no file manager is supplied to * the compiler. However, the compiler must work with other file * managers, provided they meet the requirements detailed in the methods * below. Such file managers allow the user to customise how the compiler * reads and writes files, and can be shared between multiple compilation * tasks. Such reuse between different tasks can potentially provide * a performance improvement.
*The standard file manager returned by this interface is an instance * of the subinterface, {@link StandardJavaFileManager}, which is intended * for operating on regular files and provides additional methods to support * this.
*All file managers return a {@link FileObject} which provides an * abstraction from the underlying file. The class {@link SimpleJavaFileObject} * is provided as a means to simplifying implementing this interface.
*As file managers and file objects are provided as return values from * the methods of {@link JavaCompiler} and the file manager respectively, * there is no means to override their behaviour by subclassing. Instead, * it is necessary to wrap the returned instance in another implementation * and forward method calls to it as appropriate. The classes * {@link ForwardingJavaFileManager}, {@link ForwardingFileObject} and * {@link ForwardingJavaFileObject} facilitate this by providing an * implementation that simply forwards to another, which can then be subclassed * to provide additional behaviour.
* * @author Andrew John Hughes (gnu_andrew@member.fsf.org) * @since 1.6 */ public interface JavaCompiler extends Tool, OptionChecker { /** * Interface representing a compilation task as an asynchronous * event or {@link java.util.concurrent.Future}. The task may be * started by invoking {@link #call()}. Prior to this, the task * may be configured by the user using the other methods of this * interface. * * @author Andrew John Hughes (gnu_andrew@member.fsf.org) * @since 1.6 */ public static interface CompilationTask extends Callable