java.lang.Object
com.sun.source.util.JavacTask
- All Implemented Interfaces:
Callable<Boolean>,JavaCompiler.CompilationTask
Provides access to functionality specific to the JDK Java Compiler, javac.
- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddTaskListener(TaskListener taskListener) Adds a specified listener so that it receives notification of events describing the progress of this compilation task.analyze()Completes all analysis.abstract Iterable<? extends JavaFileObject>generate()Generates code.abstract ElementsReturns a utility object for dealing with program elements.abstract TypeMirrorgetTypeMirror(Iterable<? extends Tree> path) Returns a type mirror of the tree node determined by the specified path.abstract TypesgetTypes()Returns a utility object for dealing with type mirrors.static JavacTaskinstance(ProcessingEnvironment processingEnvironment) Returns theJavacTaskfor aProcessingEnvironment.abstract Iterable<? extends CompilationUnitTree>parse()Parses the specified files returning a list of abstract syntax trees.abstract voidremoveTaskListener(TaskListener taskListener) Removes the specified listener so that it no longer receives notification of events describing the progress of this compilation task.voidSets the specifiedParameterNameProvider.abstract voidsetTaskListener(TaskListener taskListener) Sets a specified listener to receive notification of events describing the progress of this compilation task.Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface javax.tools.JavaCompiler.CompilationTask
addModules, call, setLocale, setProcessors
-
Constructor Details
-
JavacTask
public JavacTask()Constructor for subclasses to call.
-
-
Method Details
-
instance
Returns theJavacTaskfor aProcessingEnvironment. If the compiler is being invoked using aCompilationTask, then that task will be returned.- Parameters:
processingEnvironment- the processing environment- Returns:
- the
JavacTaskfor aProcessingEnvironment - Since:
- 1.8
-
parse
Parses the specified files returning a list of abstract syntax trees.- Returns:
- a list of abstract syntax trees
- Throws:
IOException- if an unhandled I/O error occurred in the compiler.IllegalStateException- if the operation cannot be performed at this time.
-
analyze
Completes all analysis.- Returns:
- a list of elements that were analyzed
- Throws:
IOException- if an unhandled I/O error occurred in the compiler.IllegalStateException- if the operation cannot be performed at this time.
-
generate
Generates code.- Returns:
- a list of files that were generated
- Throws:
IOException- if an unhandled I/O error occurred in the compiler.IllegalStateException- if the operation cannot be performed at this time.
-
setTaskListener
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 callingremoveTaskListenerfor any listener that has been previously set, followed byaddTaskListenerfor the new listener.- Parameters:
taskListener- the task listener- Throws:
IllegalStateException- if the specified listener has already been added.
-
addTaskListener
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- the task listener- Throws:
IllegalStateException- if the specified listener has already been added.- Since:
- 1.8
-
removeTaskListener
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- the task listener- Since:
- 1.8
-
setParameterNameProvider
Sets the specifiedParameterNameProvider. It may be used whenVariableElement.getSimpleName()is called for a method parameter for which an authoritative name is not found. The givenParameterNameProvidermay infer a user-friendly name for the method parameter. Setting a newParameterNameProviderwill clear any previously setParameterNameProvider, which won't be queried any more. When noParameterNameProvideris set, or when it returns null fromParameterNameProvider.getParameterName(javax.lang.model.element.VariableElement), an automatically synthesized name is returned fromVariableElement.getSimpleName().- Implementation Requirements:
- The default implementation of this method does nothing.
- Parameters:
provider- the provider- Since:
- 13
-
getTypeMirror
Returns a type mirror of the tree node determined by the specified path. This method has been superseded by methods onTrees.- Parameters:
path- the path- Returns:
- the type mirror
- See Also:
-
getElements
Returns a utility object for dealing with program elements.- Returns:
- a utility object for dealing with program elements
-
getTypes
Returns a utility object for dealing with type mirrors.- Returns:
- the utility object for dealing with type mirrors
-