com.sun.tools.javac.api
Class JavacTool

java.lang.Object
  extended by com.sun.tools.javac.api.JavacTool
All Implemented Interfaces:
JavaCompiler, OptionChecker, Tool

public final class JavacTool
extends java.lang.Object
implements JavaCompiler

TODO: describe com.sun.tools.javac.api.Tool

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.tools.JavaCompiler
JavaCompiler.CompilationTask
 
Field Summary
private  boolean compilationInProgress
           
private  Context dummyContext
           
private  java.util.List<Pair<java.lang.String,java.lang.String>> options
           
private  Main sharedCompiler
           
private  java.io.PrintWriter silent
           
 
Constructor Summary
JavacTool()
          Deprecated. 
 
Method Summary
private  java.lang.String argsToString(java.lang.Object... args)
           
(package private)  void beginContext(Context context)
          Register that a compilation is about to start.
static JavacTool create()
          Static factory method for creating new instances of this tool.
(package private)  void endContext()
          Register that a compilation is completed.
 java.util.Set<SourceVersion> getSourceVersions()
          Gets the source versions of the Java™ programming language supported by this tool.
 JavacFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, java.util.Locale locale, java.nio.charset.Charset charset)
          Gets a new instance of the standard file manager implementation for this tool.
 JavacTask getTask(java.io.Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, java.lang.Iterable<java.lang.String> options, java.lang.Iterable<java.lang.String> classes, java.lang.Iterable<? extends JavaFileObject> compilationUnits)
          Creates a future for a compilation task with the given components and arguments.
 int isSupportedOption(java.lang.String option)
          Determines if the given option is supported and if so, the number of arguments the option takes.
private static boolean match(JavacOption.OptionKind clientKind, JavacOption.OptionKind optionKind)
           
private static void processOptions(Context context, JavaFileManager fileManager, java.lang.Iterable<java.lang.String> options)
           
 int run(java.io.InputStream in, java.io.OutputStream out, java.io.OutputStream err, java.lang.String... arguments)
          Run the tool with the given I/O channels and arguments.
 void setExtendedOption(java.lang.String name, java.lang.Object... args)
           
 void setOption(java.lang.String name, java.lang.Object... args)
           
private  void setOption1(java.lang.String name, JavacOption.OptionKind kind, java.lang.Object... args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

private final java.util.List<Pair<java.lang.String,java.lang.String>> options

dummyContext

private final Context dummyContext

silent

private final java.io.PrintWriter silent

sharedCompiler

private final Main sharedCompiler

compilationInProgress

private boolean compilationInProgress
Constructor Detail

JavacTool

@Deprecated
public JavacTool()
Deprecated. 

Constructor used by service provider mechanism. The correct way to obtain an instance of this class is using create or the service provider mechanism.

See Also:
javax.tools.JavaCompilerTool, ToolProvider, create()
Method Detail

create

public static JavacTool create()
Static factory method for creating new instances of this tool.

Returns:
new instance of this tool

argsToString

private java.lang.String argsToString(java.lang.Object... args)

setOption1

private void setOption1(java.lang.String name,
                        JavacOption.OptionKind kind,
                        java.lang.Object... args)

setOption

public void setOption(java.lang.String name,
                      java.lang.Object... args)

setExtendedOption

public void setExtendedOption(java.lang.String name,
                              java.lang.Object... args)

match

private static boolean match(JavacOption.OptionKind clientKind,
                             JavacOption.OptionKind optionKind)

getStandardFileManager

public JavacFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener,
                                               java.util.Locale locale,
                                               java.nio.charset.Charset charset)
Description copied from interface: JavaCompiler
Gets a new instance of the standard file manager implementation for this tool. The file manager will use the given diagnostic listener for producing any non-fatal diagnostics. Fatal errors will be signalled with the appropriate exceptions.

The standard file manager will be automatically reopened if it is accessed after calls to flush or close. The standard file manager must be usable with other tools.

Specified by:
getStandardFileManager in interface JavaCompiler
Parameters:
diagnosticListener - a diagnostic listener for non-fatal diagnostics; if null use the compiler's default method for reporting diagnostics
locale - the locale to apply when formatting diagnostics; null means the default locale.
charset - the character set used for decoding bytes; if null use the platform default
Returns:
the standard file manager

beginContext

void beginContext(Context context)
Register that a compilation is about to start.


endContext

void endContext()
Register that a compilation is completed.


getTask

public JavacTask getTask(java.io.Writer out,
                         JavaFileManager fileManager,
                         DiagnosticListener<? super JavaFileObject> diagnosticListener,
                         java.lang.Iterable<java.lang.String> options,
                         java.lang.Iterable<java.lang.String> classes,
                         java.lang.Iterable<? extends JavaFileObject> compilationUnits)
Description copied from interface: JavaCompiler
Creates a future for a compilation task with the given components and arguments. The compilation might not have completed as described in the CompilationTask interface.

If a file manager is provided, it must be able to handle all locations defined in StandardLocation.

Specified by:
getTask in interface JavaCompiler
Parameters:
out - a Writer for additional output from the compiler; use System.err if null
fileManager - a file manager; if null use the compiler's standard filemanager
diagnosticListener - a diagnostic listener; if null use the compiler's default method for reporting diagnostics
options - compiler options, null means no options
classes - class names (for annotation processing), null means no class names
compilationUnits - the compilation units to compile, null means no compilation units
Returns:
an object representing the compilation

processOptions

private static void processOptions(Context context,
                                   JavaFileManager fileManager,
                                   java.lang.Iterable<java.lang.String> options)

run

public int run(java.io.InputStream in,
               java.io.OutputStream out,
               java.io.OutputStream err,
               java.lang.String... arguments)
Description copied from interface: Tool
Run the tool with the given I/O channels and arguments. By convention a tool returns 0 for success and nonzero for errors. Any diagnostics generated will be written to either out or err in some unspecified format.

Specified by:
run in interface Tool
Parameters:
in - "standard" input; use System.in if null
out - "standard" output; use System.out if null
err - "standard" error; use System.err if null
arguments - arguments to pass to the tool
Returns:
0 for success; nonzero otherwise

getSourceVersions

public java.util.Set<SourceVersion> getSourceVersions()
Description copied from interface: Tool
Gets the source versions of the Java™ programming language supported by this tool.

Specified by:
getSourceVersions in interface Tool
Returns:
a set of supported source versions

isSupportedOption

public int isSupportedOption(java.lang.String option)
Description copied from interface: OptionChecker
Determines if the given option is supported and if so, the number of arguments the option takes.

Specified by:
isSupportedOption in interface OptionChecker
Parameters:
option - an option
Returns:
the number of arguments the given option takes or -1 if the option is not supported