com.sun.tools.apt.main
Class JavaCompiler

java.lang.Object
  extended by com.sun.tools.javac.main.JavaCompiler
      extended by com.sun.tools.apt.main.JavaCompiler
All Implemented Interfaces:
ClassReader.SourceCompleter

public class JavaCompiler
extends JavaCompiler

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 class com.sun.tools.javac.main.JavaCompiler
JavaCompiler.CompilePolicy, JavaCompiler.CompileState, JavaCompiler.CompileStates, JavaCompiler.ImplicitSourcePolicy
 
Field Summary
(package private)  java.util.Set<java.io.File> aggregateGenFiles
           
(package private)  Apt apt
          The annotation framework
(package private)  Bark bark
          The bark to be used for error reporting.
 boolean classesAsDecls
          Are class files being treated as declarations
 boolean classOutput
          Emit class files.
protected static Context.Key<JavaCompiler> compilerKey
          The context key for the compiler.
(package private)  java.util.Set<java.lang.String> genClassFileNames
           
(package private)  java.util.Set<java.lang.String> genSourceFileNames
           
private  boolean hasBeenUsed
          Track when the JavaCompiler has been used to compile something.
(package private)  Log log
          The log to be used for error reporting.
 boolean nocompile
          Compilation should not be done after annotation processing.
 boolean print
          The internal printing annotation processor should be used.
 
Fields inherited from class com.sun.tools.javac.main.JavaCompiler
annotate, annotationProcessingOccurred, attr, attrParseOnly, chk, compilePolicy, completionFailureName, context, delegateCompiler, devVerbose, elapsed_msec, encoding, enter, explicitAnnotationProcessingRequested, fileManager, flow, gen, genEndPos, implicitSourceFilesRead, implicitSourcePolicy, inputFiles, keepComments, lineDebugInfo, lower, make, names, parserFactory, printFlat, processPcks, reader, source, sourceOutput, stubOutput, syms, taskListener, todo, transStaging, transTypes, types, verbose, verboseCompilePolicy, writer
 
Constructor Summary
JavaCompiler(Context context)
          Construct a new compiler from a shared context.
 
Method Summary
 List<Symbol.ClassSymbol> compile(List<java.lang.String> filenames, java.util.Map<java.lang.String,java.lang.String> origOptions, java.lang.ClassLoader aptCL, AnnotationProcessorFactory providedFactory, java.util.Set<java.lang.Class<? extends AnnotationProcessorFactory>> productiveFactories, java.util.Set<java.io.File> aggregateGenFiles)
          Main method: compile a list of files, return all compiled classes
 java.util.Set<java.io.File> getAggregateGenFiles()
           
 java.util.Set<java.lang.String> getClassFileNames()
          List of names of generated class files.
 java.util.Set<java.lang.String> getSourceFileNames()
           
static JavaCompiler instance(Context context)
          Get the JavaCompiler instance for this context.
protected  boolean keepComments()
           
protected  JCTree.JCCompilationUnit parse(JavaFileObject filename, java.lang.CharSequence content)
          Parse contents of input stream.
private static Context preRegister(Context context)
           
 java.lang.CharSequence readSource(JavaFileObject filename)
          Try to open input stream with given name.
 
Methods inherited from class com.sun.tools.javac.main.JavaCompiler
attribute, attribute, close, close, compile, compile, complete, desugar, desugar, enableLogging, enterTrees, errorCount, flow, flow, flow, fullVersion, generate, generate, initProcessAnnotations, initRound, parse, parse, parseErrors, parseFiles, printCount, printVerbose, processAnnotations, processAnnotations, reportDeferredDiagnostics, resolveIdent, stopIfError, stopIfError, version, warningCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compilerKey

protected static final Context.Key<JavaCompiler> compilerKey
The context key for the compiler.


genSourceFileNames

java.util.Set<java.lang.String> genSourceFileNames

genClassFileNames

java.util.Set<java.lang.String> genClassFileNames

aggregateGenFiles

java.util.Set<java.io.File> aggregateGenFiles

bark

Bark bark
The bark to be used for error reporting.


log

Log log
The log to be used for error reporting.


apt

Apt apt
The annotation framework


classOutput

public boolean classOutput
Emit class files. This switch is always set, except for the first phase of retrofitting, where signatures are parsed.


print

public boolean print
The internal printing annotation processor should be used.


nocompile

public boolean nocompile
Compilation should not be done after annotation processing.


classesAsDecls

public boolean classesAsDecls
Are class files being treated as declarations


hasBeenUsed

private boolean hasBeenUsed
Track when the JavaCompiler has been used to compile something.

Constructor Detail

JavaCompiler

public JavaCompiler(Context context)
Construct a new compiler from a shared context.

Method Detail

instance

public static JavaCompiler instance(Context context)
Get the JavaCompiler instance for this context.


getSourceFileNames

public java.util.Set<java.lang.String> getSourceFileNames()

getClassFileNames

public java.util.Set<java.lang.String> getClassFileNames()
List of names of generated class files.


getAggregateGenFiles

public java.util.Set<java.io.File> getAggregateGenFiles()

preRegister

private static Context preRegister(Context context)

readSource

public java.lang.CharSequence readSource(JavaFileObject filename)
Try to open input stream with given name. Report an error if this fails.

Overrides:
readSource in class JavaCompiler
Parameters:
filename - The file name of the input stream to be opened.

parse

protected JCTree.JCCompilationUnit parse(JavaFileObject filename,
                                         java.lang.CharSequence content)
Parse contents of input stream.

Overrides:
parse in class JavaCompiler
Parameters:
filename - The name of the file from which input stream comes.
input - The input stream to be parsed.

keepComments

protected boolean keepComments()
Overrides:
keepComments in class JavaCompiler

compile

public List<Symbol.ClassSymbol> compile(List<java.lang.String> filenames,
                                        java.util.Map<java.lang.String,java.lang.String> origOptions,
                                        java.lang.ClassLoader aptCL,
                                        AnnotationProcessorFactory providedFactory,
                                        java.util.Set<java.lang.Class<? extends AnnotationProcessorFactory>> productiveFactories,
                                        java.util.Set<java.io.File> aggregateGenFiles)
                                 throws java.lang.Throwable
Main method: compile a list of files, return all compiled classes

Parameters:
filenames - The names of all files to be compiled.
Throws:
java.lang.Throwable