com.sun.tools.javac.api
Class JavacTaskImpl

java.lang.Object
  extended by com.sun.source.util.JavacTask
      extended by com.sun.tools.javac.api.JavacTaskImpl
All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Boolean>, JavaCompiler.CompilationTask

public class JavacTaskImpl
extends JavacTask

Provides access to functionality specific to the Sun Java Compiler, javac.

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
(package private)  class JavacTaskImpl.Filter
           
 
Field Summary
private  java.lang.String[] args
           
private  JavaCompiler compiler
           
private  Main compilerMain
           
private  Context context
           
private  List<JavaFileObject> fileObjects
           
private  ListBuffer<Env<AttrContext>> genList
           
private  java.util.Locale locale
           
private  java.util.Map<JavaFileObject,JCTree.JCCompilationUnit> notYetEntered
           
private  boolean parsed
           
private  java.lang.Iterable<? extends Processor> processors
           
private  java.lang.Integer result
           
private  TaskListener taskListener
           
private  JavacTool tool
           
private  java.util.concurrent.atomic.AtomicBoolean used
           
 
Constructor Summary
JavacTaskImpl(JavacTool tool, Main compilerMain, java.lang.Iterable<java.lang.String> flags, Context context, java.lang.Iterable<java.lang.String> classes, java.lang.Iterable<? extends JavaFileObject> fileObjects)
           
JavacTaskImpl(JavacTool tool, Main compilerMain, java.lang.String[] args, Context context, List<JavaFileObject> fileObjects)
           
 
Method Summary
 java.lang.Iterable<? extends Element> analyze()
          Complete all analysis.
 java.lang.Iterable<? extends Element> analyze(java.lang.Iterable<? extends TypeElement> classes)
          Complete all analysis on the given classes.
 JavaFileObject asJavaFileObject(java.io.File file)
          Construct a JavaFileObject from the given file.
private  void beginContext()
           
 java.lang.Boolean call()
          Performs this compilation task.
private  void endContext()
           
 java.lang.Iterable<? extends TypeElement> enter()
          Translate all the abstract syntax trees to elements.
 java.lang.Iterable<? extends TypeElement> enter(java.lang.Iterable<? extends CompilationUnitTree> trees)
          Translate the given abstract syntax trees to elements.
 java.lang.Iterable<? extends JavaFileObject> generate()
          Generate code.
 java.lang.Iterable<? extends JavaFileObject> generate(java.lang.Iterable<? extends TypeElement> classes)
          Generate code corresponding to the given classes.
 Context getContext()
          For internal use by Sun Microsystems only.
 JavacElements getElements()
          Get a utility object for dealing with program elements.
 TypeMirror getTypeMirror(java.lang.Iterable<? extends Tree> path)
          Get a type mirror of the tree node determined by the specified path.
 JavacTypes getTypes()
          Get a utility object for dealing with type mirrors.
private  void handleFlowResults(java.util.Queue<Env<AttrContext>> queue, ListBuffer<Element> elems)
           
 java.lang.Iterable<? extends CompilationUnitTree> parse()
          Parse the specified files returning a list of abstract syntax trees.
 Type parseType(java.lang.String expr, TypeElement scope)
          For internal use by Sun Microsystems only.
 java.lang.Iterable<? extends Tree> pathFor(CompilationUnitTree unit, Tree node)
           
private  void prepareCompiler()
           
 void setLocale(java.util.Locale locale)
          Set the locale to be applied when formatting diagnostics and other localized data.
 void setProcessors(java.lang.Iterable<? extends Processor> processors)
          Sets processors (for annotation processing).
 void setTaskListener(TaskListener taskListener)
          The specified listener will receive events describing the progress of this compilation task.
private static java.lang.String[] toArray(java.lang.Iterable<java.lang.String> flags, java.lang.Iterable<java.lang.String> classes)
           
private static List<JavaFileObject> toList(java.lang.Iterable<? extends JavaFileObject> fileObjects)
           
 void updateContext(Context newContext)
          For internal use by Sun Microsystems only.
private  TaskListener wrap(TaskListener tl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tool

private JavacTool tool

compilerMain

private Main compilerMain

compiler

private JavaCompiler compiler

locale

private java.util.Locale locale

args

private java.lang.String[] args

context

private Context context

fileObjects

private List<JavaFileObject> fileObjects

notYetEntered

private java.util.Map<JavaFileObject,JCTree.JCCompilationUnit> notYetEntered

genList

private ListBuffer<Env<AttrContext>> genList

taskListener

private TaskListener taskListener

used

private java.util.concurrent.atomic.AtomicBoolean used

processors

private java.lang.Iterable<? extends Processor> processors

result

private java.lang.Integer result

parsed

private boolean parsed
Constructor Detail

JavacTaskImpl

JavacTaskImpl(JavacTool tool,
              Main compilerMain,
              java.lang.String[] args,
              Context context,
              List<JavaFileObject> fileObjects)

JavacTaskImpl

JavacTaskImpl(JavacTool tool,
              Main compilerMain,
              java.lang.Iterable<java.lang.String> flags,
              Context context,
              java.lang.Iterable<java.lang.String> classes,
              java.lang.Iterable<? extends JavaFileObject> fileObjects)
Method Detail

toArray

private static java.lang.String[] toArray(java.lang.Iterable<java.lang.String> flags,
                                          java.lang.Iterable<java.lang.String> classes)

toList

private static List<JavaFileObject> toList(java.lang.Iterable<? extends JavaFileObject> fileObjects)

call

public java.lang.Boolean call()
Description copied from interface: JavaCompiler.CompilationTask
Performs this compilation task. The compilation may only be performed once. Subsequent calls to this method throw IllegalStateException.

Returns:
true if and only all the files compiled without errors; false otherwise

setProcessors

public void setProcessors(java.lang.Iterable<? extends Processor> processors)
Description copied from interface: JavaCompiler.CompilationTask
Sets processors (for annotation processing). This will bypass the normal discovery mechanism.

Parameters:
processors - processors (for annotation processing)

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: JavaCompiler.CompilationTask
Set the locale to be applied when formatting diagnostics and other localized data.

Parameters:
locale - the locale to apply; null means apply no locale

prepareCompiler

private void prepareCompiler()
                      throws java.io.IOException
Throws:
java.io.IOException

beginContext

private void beginContext()

wrap

private TaskListener wrap(TaskListener tl)

endContext

private void endContext()

asJavaFileObject

public JavaFileObject asJavaFileObject(java.io.File file)
Construct a JavaFileObject from the given file.

TODO: this method is useless here

Parameters:
file - a file
Returns:
a JavaFileObject from the standard file manager.

setTaskListener

public void setTaskListener(TaskListener taskListener)
Description copied from class: JavacTask
The specified listener will receive events describing the progress of this compilation task.

Specified by:
setTaskListener in class JavacTask

parse

public java.lang.Iterable<? extends CompilationUnitTree> parse()
                                                        throws java.io.IOException
Parse the specified files returning a list of abstract syntax trees.

Specified by:
parse in class JavacTask
Returns:
a list of abstract syntax trees
Throws:
java.io.IOException - TODO

enter

public java.lang.Iterable<? extends TypeElement> enter()
                                                throws java.io.IOException
Translate all the abstract syntax trees to elements.

Returns:
a list of elements corresponding to the top level classes in the abstract syntax trees
Throws:
java.io.IOException - TODO

enter

public java.lang.Iterable<? extends TypeElement> enter(java.lang.Iterable<? extends CompilationUnitTree> trees)
                                                throws java.io.IOException
Translate the given abstract syntax trees to elements.

Parameters:
trees - a list of abstract syntax trees.
Returns:
a list of elements corresponding to the top level classes in the abstract syntax trees
Throws:
java.io.IOException - TODO

analyze

public java.lang.Iterable<? extends Element> analyze()
                                              throws java.io.IOException
Complete all analysis.

Specified by:
analyze in class JavacTask
Returns:
a list of elements that were analyzed
Throws:
java.io.IOException - TODO

analyze

public java.lang.Iterable<? extends Element> analyze(java.lang.Iterable<? extends TypeElement> classes)
                                              throws java.io.IOException
Complete all analysis on the given classes. This can be used to ensure that all compile time errors are reported. The classes must have previously been returned from enter(). If null is specified, all outstanding classes will be analyzed.

Parameters:
classes - a list of class elements
Throws:
java.io.IOException

handleFlowResults

private void handleFlowResults(java.util.Queue<Env<AttrContext>> queue,
                               ListBuffer<Element> elems)

generate

public java.lang.Iterable<? extends JavaFileObject> generate()
                                                      throws java.io.IOException
Generate code.

Specified by:
generate in class JavacTask
Returns:
a list of files that were generated
Throws:
java.io.IOException - TODO

generate

public java.lang.Iterable<? extends JavaFileObject> generate(java.lang.Iterable<? extends TypeElement> classes)
                                                      throws java.io.IOException
Generate code corresponding to the given classes. The classes must have previously been returned from enter(). If there are classes outstanding to be analyzed, that will be done before any classes are generated. If null is specified, code will be generated for all outstanding classes.

Parameters:
classes - a list of class elements
Throws:
java.io.IOException

getTypeMirror

public TypeMirror getTypeMirror(java.lang.Iterable<? extends Tree> path)
Description copied from class: JavacTask
Get a type mirror of the tree node determined by the specified path.

Specified by:
getTypeMirror in class JavacTask

getElements

public JavacElements getElements()
Description copied from class: JavacTask
Get a utility object for dealing with program elements.

Specified by:
getElements in class JavacTask

getTypes

public JavacTypes getTypes()
Description copied from class: JavacTask
Get a utility object for dealing with type mirrors.

Specified by:
getTypes in class JavacTask

pathFor

public java.lang.Iterable<? extends Tree> pathFor(CompilationUnitTree unit,
                                                  Tree node)

getContext

public Context getContext()
For internal use by Sun Microsystems only. This method will be removed without warning.


updateContext

public void updateContext(Context newContext)
For internal use by Sun Microsystems only. This method will be removed without warning.


parseType

public Type parseType(java.lang.String expr,
                      TypeElement scope)
For internal use by Sun Microsystems only. This method will be removed without warning.