APIdia Launch Partner
Top Description Constructors Methods
com.sun.source.util

public abstract Class JavacTask

extends Object
implements CompilationTask
Class Inheritance
All Implemented Interfaces
javax.tools.JavaCompiler.CompilationTask, java.util.concurrent.Callable
Known Direct Subclasses
com.sun.tools.javac.api.BasicJavacTask
Imports
java.io.IOException, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.element.Element, .VariableElement, javax.lang.model.type.TypeMirror, javax.lang.model.util.Elements, .Types, javax.tools.JavaCompiler.CompilationTask, .JavaFileObject, com.sun.source.tree.CompilationUnitTree, .Tree, com.sun.tools.javac.api.BasicJavacTask, com.sun.tools.javac.processing.JavacProcessingEnvironment, com.sun.tools.javac.util.Context

Provides access to functionality specific to the JDK Java Compiler, javac.
Authors
Peter von der Ahé, Jonathan Gibbons
Since
1.6

Constructor Summary

AccessConstructor and Description
protected
JavacTask()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract void
addTaskListener(TaskListener
the task listener
taskListener
)

Adds a specified listener so that it receives notification of events describing the progress of this compilation task.

public abstract Iterable<? extends Element>

Returns:

a list of elements that were analyzed
analyze
()

Completes all analysis.

public abstract Iterable<? extends JavaFileObject>

Returns:

a list of files that were generated
generate
()

Generates code.

public abstract Elements

Returns:

a utility object for dealing with program elements
getElements
()

Returns a utility object for dealing with program elements.

public abstract TypeMirror

Returns:

the type mirror
getTypeMirror
(Iterable<? extends Tree>
the path
path
)

Returns a type mirror of the tree node determined by the specified path.

public abstract Types

Returns:

the utility object for dealing with type mirrors
getTypes
()

Returns a utility object for dealing with type mirrors.

public static JavacTask

Returns:

the JavacTask for a ProcessingEnvironment
instance
(ProcessingEnvironment
the processing environment
processingEnvironment
)

Returns the JavacTask for a ProcessingEnvironment.

public abstract Iterable<? extends CompilationUnitTree>

Returns:

a list of abstract syntax trees
parse
()

Parses the specified files returning a list of abstract syntax trees.

public abstract void
removeTaskListener(TaskListener
the task listener
taskListener
)

Removes the specified listener so that it no longer receives notification of events describing the progress of this compilation task.

public void
setParameterNameProvider(ParameterNameProvider
the provider
provider
)

Sets the specified ParameterNameProvider.

public abstract void
setTaskListener(TaskListener
the task listener
taskListener
)

Sets a specified listener to receive notification of events describing the progress of this compilation task.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JavacTaskback to summary
protected JavacTask()

Constructor for subclasses to call.

Method Detail

addTaskListenerback to summary
public abstract void addTaskListener(TaskListener taskListener)

Adds a specified listener so that it receives notification of events describing the progress of this compilation task. This method may be called at any time before or during the compilation.

Parameters
taskListener:TaskListener

the task listener

Exceptions
IllegalStateException:
if the specified listener has already been added.
Since
1.8
analyzeback to summary
public abstract Iterable<? extends Element> analyze() throws IOException

Completes all analysis.

Returns:Iterable<? extends Element>

a list of elements that were analyzed

Exceptions
IOException:
if an unhandled I/O error occurred in the compiler.
IllegalStateException:
if the operation cannot be performed at this time.
generateback to summary
public abstract Iterable<? extends JavaFileObject> generate() throws IOException

Generates code.

Returns:Iterable<? extends JavaFileObject>

a list of files that were generated

Exceptions
IOException:
if an unhandled I/O error occurred in the compiler.
IllegalStateException:
if the operation cannot be performed at this time.
getElementsback to summary
public abstract Elements getElements()

Returns a utility object for dealing with program elements.

Returns:Elements

a utility object for dealing with program elements

getTypeMirrorback to summary
public abstract TypeMirror getTypeMirror(Iterable<? extends Tree> path)

Returns a type mirror of the tree node determined by the specified path. This method has been superseded by methods on Trees.

Parameters
path:Iterable<? extends Tree>

the path

Returns:TypeMirror

the type mirror

See Also
com.sun.source.util.Trees#getTypeMirror
getTypesback to summary
public abstract Types getTypes()

Returns a utility object for dealing with type mirrors.

Returns:Types

the utility object for dealing with type mirrors

instanceback to summary
public static JavacTask instance(ProcessingEnvironment processingEnvironment)

Returns the JavacTask for a ProcessingEnvironment. If the compiler is being invoked using a CompilationTask, then that task will be returned.

Parameters
processingEnvironment:ProcessingEnvironment

the processing environment

Returns:JavacTask

the JavacTask for a ProcessingEnvironment

Since
1.8
parseback to summary
public abstract Iterable<? extends CompilationUnitTree> parse() throws IOException

Parses the specified files returning a list of abstract syntax trees.

Returns:Iterable<? extends CompilationUnitTree>

a list of abstract syntax trees

Exceptions
IOException:
if an unhandled I/O error occurred in the compiler.
IllegalStateException:
if the operation cannot be performed at this time.
removeTaskListenerback to summary
public abstract void removeTaskListener(TaskListener taskListener)

Removes the specified listener so that it no longer receives notification of events describing the progress of this compilation task. This method may be called at any time before or during the compilation.

Parameters
taskListener:TaskListener

the task listener

Since
1.8
setParameterNameProviderback to summary
public void setParameterNameProvider(ParameterNameProvider provider)

Sets the specified ParameterNameProvider. It may be used when VariableElement#getSimpleName() is called for a method parameter for which an authoritative name is not found. The given ParameterNameProvider may infer a user-friendly name for the method parameter. Setting a new ParameterNameProvider will clear any previously set ParameterNameProvider, which won't be queried any more. When no ParameterNameProvider is set, or when it returns null from ParameterNameProvider#getParameterName(javax.lang.model.element.VariableElement), an automatically synthesized name is returned from VariableElement.getSimpleName().

Implementation Specification

The default implementation of this method does nothing.

Parameters
provider:ParameterNameProvider

the provider

Since
13
setTaskListenerback to summary
public abstract void setTaskListener(TaskListener taskListener)

Sets a specified listener to receive notification of events describing the progress of this compilation task. If another listener is receiving notifications as a result of a prior call of this method, then that listener will no longer receive notifications. Informally, this method is equivalent to calling removeTaskListener for any listener that has been previously set, followed by addTaskListener for the new listener.

Parameters
taskListener:TaskListener

the task listener

Exceptions
IllegalStateException:
if the specified listener has already been added.