/*
* @(#)JavaCompiler.java 1.15 06/09/25
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.tools;
import java.io.File;
import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import javax.annotation.processing.Processor;
/**
* Interface to invoke Java™ programming language compilers from
* programs.
*
* <p>The compiler might generate diagnostics during compilation (for
* example, error messages). If a diagnostic listener is provided,
* the diagnostics will be supplied to the listener. If no listener
* is provided, the diagnostics will be formatted in an unspecified
* format and written to the default output, which is {@code
* System.err} unless otherwise specified. Even if a diagnostic
* listener is supplied, some diagnostics might not fit in a {@code
* Diagnostic} and will be written to the default output.
*
* <p>A compiler tool has an associated standard file manager, which
* is the file manager that is native to the tool (or built-in). The
* standard file manager can be obtained by calling {@linkplain
* #getStandardFileManager getStandardFileManager}.
*
* <p>A compiler tool must function with any file manager as long as
* any additional requirements as detailed in the methods below are
* met. If no file manager is provided, the compiler tool will use a
* standard file manager such as the one returned by {@linkplain
* #getStandardFileManager getStandardFileManager}.
*
* <p>An instance implementing this interface must conform to the Java
* Language Specification and generate class files conforming to the
* Java Virtual Machine specification. The versions of these
* specifications are defined in the {@linkplain Tool} interface.
*
* Additionally, an instance of this interface supporting {@link
* javax.lang.model.SourceVersion#RELEASE_6 SourceVersion.RELEASE_6}
* or higher must also support {@linkplain javax.annotation.processing
* annotation processing}.
*
* <p>The compiler relies on two services: {@linkplain
* DiagnosticListener diagnostic listener} and {@linkplain
* JavaFileManager file manager}. Although most classes and
* interfaces in this package defines an API for compilers (and
* tools in general) the interfaces {@linkplain DiagnosticListener},
* {@linkplain JavaFileManager}, {@linkplain FileObject}, and
* {@linkplain JavaFileObject} are not intended to be used in
* applications. Instead these interfaces are intended to be
* implemented and used to provide customized services for a
* compiler and thus defines an SPI for compilers.
*
* <p>There are a number of classes and interfaces in this package
* which are designed to ease the implementation of the SPI to
* customize the behavior of a compiler:
*
* <dl>
* <dt>{@link StandardJavaFileManager}</dt>
* <dd>
*
* Every compiler which implements this interface provides a
* standard file manager for operating on regular {@linkplain
* java.io.File files}. The StandardJavaFileManager interface
* defines additional methods for creating file objects from
* regular files.
*
* <p>The standard file manager serves two purposes:
*
* <ul>
* <li>basic building block for customizing how a compiler reads
* and writes files</li>
* <li>sharing between multiple compilation tasks</li>
* </ul>
*
* <p>Reusing a file manager can potentially reduce overhead of
* scanning the file system and reading jar files. Although there
* might be no reduction in overhead, a standard file manager must
* work with multiple sequential compilations making the following
* example a recommended coding pattern:
*
* <pre>
* Files[] files1 = ... ; // input for first compilation task
* Files[] files2 = ... ; // input for second compilation task
*
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
*
* {@code Iterable<? extends JavaFileObject>} compilationUnits1 =
* fileManager.getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files1));
=1= |