Top Description Constructors Methods
com.sun.tools.javac.api

public final Class JavacTool

extends Object
implements JavaCompiler
Class Inheritance
All Implemented Interfaces
javax.tools.JavaCompiler, javax.tools.OptionChecker, javax.tools.Tool
Imports
java.io.InputStream, .OutputStream, .OutputStreamWriter, .PrintWriter, .Writer, java.nio.charset.Charset, java.util.Collections, .EnumSet, .Locale, .Objects, .Set, javax.lang.model.SourceVersion, javax.tools.*, com.sun.source.util.JavacTask, com.sun.tools.javac.file.JavacFileManager, .BaseFileManager, .CacheFSInfo, com.sun.tools.javac.main.Arguments, .Option, com.sun.tools.javac.jvm.Target, com.sun.tools.javac.util.ClientCodeException, .Context, .DefinedBy, .DefinedBy.Api, .List, .Log, .PropagatedException

Todo

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

This is NOT part of any supported API. 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.

Author
Peter von der Ahé

Constructor Summary

AccessConstructor and Description
public
JavacTool()

Deprecated
Constructor used by service provider mechanism.

Method Summary

Modifier and TypeMethod and Description
public static JavacTool

Returns:

new instance of this tool
create
()

Static factory method for creating new instances of this tool.

public Set<SourceVersion>
getSourceVersions()

Implements javax.tools.Tool.getSourceVersions.

Returns the source versions of the Java programming language supported by this tool.
public JavacFileManager
getStandardFileManager(DiagnosticListener<? super JavaFileObject>
a diagnostic listener for non-fatal diagnostics; if null use the compiler's default method for reporting diagnostics
diagnosticListener
,
Locale
the locale to apply when formatting diagnostics; null means the default locale.
locale
,
Charset
the character set used for decoding bytes; if null use the platform default
charset
)

Implements javax.tools.JavaCompiler.getStandardFileManager.

Returns a new instance of the standard file manager implementation for this tool.
public JavacTask
getTask(Writer
a Writer for additional output from the compiler; use System.err if null
out
,
JavaFileManager
a file manager; if null use the compiler's standard file manager
fileManager
,
DiagnosticListener<? super JavaFileObject>
a diagnostic listener; if null use the compiler's default method for reporting diagnostics
diagnosticListener
,
Iterable<String>
compiler options, null means no options
options
,
Iterable<String>
names of classes to be processed by annotation processing, null means no class names
classes
,
Iterable<? extends JavaFileObject>
the compilation units to compile, null means no compilation units
compilationUnits
)

Implements javax.tools.JavaCompiler.getTask.

Creates a future for a compilation task with the given components and arguments.
public JavacTask
getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits, Context context)

public int
isSupportedOption(String
an option
option
)

Implements javax.tools.OptionChecker.isSupportedOption.

Determines if the given option is supported and if so, the number of arguments the option takes.
public String
name()

Overrides default javax.tools.Tool.name.

Returns the name of this tool, or an empty string if no name is provided.
public int
run(InputStream
"standard" input; use System.in if null
in
,
OutputStream
"standard" output; use System.out if null
out
,
OutputStream
"standard" error; use System.err if null
err
,
String...
arguments to pass to the tool
arguments
)

Implements javax.tools.Tool.run.

Run the tool with the given I/O channels and arguments.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JavacToolback to summary
public JavacTool()

Deprecated

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

Annotations
@Deprecated
See Also
javax.tools.JavaCompiler, javax.tools.ToolProvider, create

Method Detail

createback to summary
public static JavacTool create()

Static factory method for creating new instances of this tool.

Returns:JavacTool

new instance of this tool

getSourceVersionsback to summary
public Set<SourceVersion> getSourceVersions()

Implements javax.tools.Tool.getSourceVersions.

Doc from javax.tools.Tool.getSourceVersions.

Returns the source versions of the Java programming language supported by this tool.

Returns:Set<SourceVersion>

a set of supported source versions

Annotations
@Override
@DefinedBy:COMPILER
getStandardFileManagerback to summary
public JavacFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset)

Implements javax.tools.JavaCompiler.getStandardFileManager.

Doc from javax.tools.JavaCompiler.getStandardFileManager.

Returns 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 signaled 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.

Parameters
diagnosticListener:DiagnosticListener<? super JavaFileObject>

a diagnostic listener for non-fatal diagnostics; if null use the compiler's default method for reporting diagnostics

locale:Locale

the locale to apply when formatting diagnostics; null means the default locale.

charset:Charset

the character set used for decoding bytes; if null use the platform default

Returns:JavacFileManager

the standard file manager

Annotations
@Override
@DefinedBy:COMPILER
getTaskback to summary
public JavacTask getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits)

Implements javax.tools.JavaCompiler.getTask.

Doc from javax.tools.JavaCompiler.getTask.

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.

Note that annotation processing can process both the compilation units of source code to be compiled, passed with the compilationUnits parameter, as well as class files, whose names are passed with the classes parameter.

Parameters
out:Writer

a Writer for additional output from the compiler; use System.err if null

fileManager:JavaFileManager

a file manager; if null use the compiler's standard file manager

diagnosticListener:DiagnosticListener<? super JavaFileObject>

a diagnostic listener; if null use the compiler's default method for reporting diagnostics

options:Iterable<String>

compiler options, null means no options

classes:Iterable<String>

names of classes to be processed by annotation processing, null means no class names

compilationUnits:Iterable<? extends JavaFileObject>

the compilation units to compile, null means no compilation units

Returns:JavacTask

an object representing the compilation

Annotations
@Override
@DefinedBy:COMPILER
getTaskback to summary
public JavacTask getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits, Context context)
isSupportedOptionback to summary
public int isSupportedOption(String option)

Implements javax.tools.OptionChecker.isSupportedOption.

Doc from javax.tools.OptionChecker.isSupportedOption.

Determines if the given option is supported and if so, the number of arguments the option takes.

Parameters
option:String

an option

Returns:int

the number of arguments the given option takes or -1 if the option is not supported

Annotations
@Override
@DefinedBy:COMPILER
nameback to summary
public String name()

Overrides default javax.tools.Tool.name.

Doc from javax.tools.Tool.name.

Returns the name of this tool, or an empty string if no name is provided.

Returns:String

the name of this tool

Annotations
@DefinedBy:COMPILER
runback to summary
public int run(InputStream in, OutputStream out, OutputStream err, String... arguments)

Implements javax.tools.Tool.run.

Doc from javax.tools.Tool.run.

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.

Parameters
in:InputStream

"standard" input; use System.in if null

out:OutputStream

"standard" output; use System.out if null

err:OutputStream

"standard" error; use System.err if null

arguments:String[]

arguments to pass to the tool

Returns:int

0 for success; nonzero otherwise

Annotations
@Override
@DefinedBy:COMPILER