com.sun.tools.apt.main
Class Main

java.lang.Object
  extended by com.sun.tools.apt.main.Main

public class Main
extends java.lang.Object

This class provides a commandline interface to the apt build-time tool.

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
private  class Main.AptHiddenOption
           
private  class Main.AptOption
           
private  class Main.AptXOption
          A nonstandard or extended (-X) option
private  class Main.HiddenOption
          A hidden (implementor) option
private  class Main.Option
          This class represents an option recognized by the main program
private  class Main.SharedOption
           
private  class Main.XOption
          A nonstandard or extended (-X) option
 
Field Summary
(package private)  java.util.Set<java.lang.String> aggregateGenClassFileNames
          List of all the generated class file names across all apt rounds.
(package private)  java.util.Set<java.io.File> aggregateGenFiles
          List of all the generated file names across all apt rounds.
(package private)  java.util.Set<java.lang.String> aggregateGenSourceFileNames
          List of all the generated source file names across all apt rounds.
(package private)  java.lang.ClassLoader aptCL
          Classloader to use for finding factories.
private static java.lang.String aptRB
           
(package private)  java.util.List<java.lang.String> classFileNames
          The list of class files to process
(package private) static int EXIT_ABNORMAL
          Result codes.
(package private) static int EXIT_CMDERR
          Result codes.
(package private) static int EXIT_ERROR
          Result codes.
(package private) static int EXIT_OK
          Result codes.
(package private) static int EXIT_SYSERR
          Result codes.
(package private) static java.lang.String[] forcedOpts
          For testing: enter any options you want to be set implicitly here.
(package private)  java.util.Set<java.lang.String> genClassFileNames
          List of names of generated class files from most recent apt round.
(package private)  java.util.Set<java.lang.String> genSourceFileNames
          List of top level names of generated source files from most recent apt round.
private static java.lang.String javacRB
           
private static java.util.ResourceBundle messageRBapt
           
private static java.util.ResourceBundle messageRBjavac
           
private  Options options
          A table of all options that's passed to the JavaCompiler constructor.
(package private)  java.util.Map<java.lang.String,java.lang.String> origOptions
          Map representing original command-line arguments.
(package private)  java.io.PrintWriter out
          The writer to use for diagnostic output.
(package private)  java.lang.String ownName
          The name of the compiler, for use in diagnostics.
(package private)  java.util.Set<java.lang.Class<? extends AnnotationProcessorFactory>> productiveFactories
          Set of all factories that have provided a processor on some apt round.
(package private)  AnnotationProcessorFactory providedFactory
          Instantiated factory to use in lieu of discovery process.
private  Main.Option[] recognizedOptions
           
(package private)  java.util.List<java.lang.String> sourceFileNames
          The list of source files to process
 
Constructor Summary
Main(java.lang.String name)
          Construct a compiler instance.
Main(java.lang.String name, java.io.PrintWriter out)
          Construct a compiler instance.
 
Method Summary
(package private)  void apMessage(AnnotationProcessingError ex)
          Print a message reporting an fatal error.
(package private)  void bugMessage(java.lang.Throwable ex)
          Print a message reporting an internal error.
 int compile(java.lang.String[] args, AnnotationProcessorFactory factory)
          Programmatic interface for main function.
(package private)  int compile(java.lang.String[] args, Context context)
          Programmatic interface for main function.
(package private)  void error(java.lang.String key, java.lang.Object... args)
          Report a usage error.
(package private)  void feMessage(java.lang.Throwable ex)
          Print a message reporting an fatal error.
(package private) static java.net.URL fileToURL(java.io.File file)
          Returns the directory or JAR file URL corresponding to the specified local file name.
private static java.lang.String getLocalizedString(java.lang.String key, java.lang.Object... args)
          Find a localized string in the resource bundle.
private static java.lang.String getText(java.lang.String key, java.lang.Object... _args)
          Get and format message string from resource.
(package private)  void help()
          Print a string that explains usage.
private static void initResource()
          Initialize ResourceBundle.
(package private)  void ioMessage(java.lang.Throwable ex)
          Print a message reporting an input/output error.
(package private) static java.net.URL[] pathToURLs(java.lang.String path)
          Utility method for converting a search path string to an array of directory and JAR file URLs.
protected  java.util.List<java.lang.String> processArgs(java.lang.String[] flags)
          Process command line arguments: store all command line options in `options' table and return all source filenames.
(package private)  void resourceMessage(java.lang.Throwable ex)
          Print a message reporting an out-of-resources error.
(package private)  void sceMessage(sun.misc.ServiceConfigurationError ex)
          Print a message about sun.misc.Service problem.
(package private)  void warning(java.lang.String key, java.lang.Object... args)
          Report a warning.
(package private)  void xhelp()
          Print a string that explains usage for X options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forcedOpts

static java.lang.String[] forcedOpts
For testing: enter any options you want to be set implicitly here.


ownName

java.lang.String ownName
The name of the compiler, for use in diagnostics.


out

java.io.PrintWriter out
The writer to use for diagnostic output.


providedFactory

AnnotationProcessorFactory providedFactory
Instantiated factory to use in lieu of discovery process.


origOptions

java.util.Map<java.lang.String,java.lang.String> origOptions
Map representing original command-line arguments.


aptCL

java.lang.ClassLoader aptCL
Classloader to use for finding factories.


EXIT_OK

static final int EXIT_OK
Result codes.

See Also:
Constant Field Values

EXIT_ERROR

static final int EXIT_ERROR
Result codes.

See Also:
Constant Field Values

EXIT_CMDERR

static final int EXIT_CMDERR
Result codes.

See Also:
Constant Field Values

EXIT_SYSERR

static final int EXIT_SYSERR
Result codes.

See Also:
Constant Field Values

EXIT_ABNORMAL

static final int EXIT_ABNORMAL
Result codes.

See Also:
Constant Field Values

recognizedOptions

private Main.Option[] recognizedOptions

options

private Options options
A table of all options that's passed to the JavaCompiler constructor.


sourceFileNames

java.util.List<java.lang.String> sourceFileNames
The list of source files to process


classFileNames

java.util.List<java.lang.String> classFileNames
The list of class files to process


genSourceFileNames

java.util.Set<java.lang.String> genSourceFileNames
List of top level names of generated source files from most recent apt round.


genClassFileNames

java.util.Set<java.lang.String> genClassFileNames
List of names of generated class files from most recent apt round.


aggregateGenSourceFileNames

java.util.Set<java.lang.String> aggregateGenSourceFileNames
List of all the generated source file names across all apt rounds.


aggregateGenClassFileNames

java.util.Set<java.lang.String> aggregateGenClassFileNames
List of all the generated class file names across all apt rounds.


aggregateGenFiles

java.util.Set<java.io.File> aggregateGenFiles
List of all the generated file names across all apt rounds.


productiveFactories

java.util.Set<java.lang.Class<? extends AnnotationProcessorFactory>> productiveFactories
Set of all factories that have provided a processor on some apt round.


javacRB

private static final java.lang.String javacRB
See Also:
Constant Field Values

aptRB

private static final java.lang.String aptRB
See Also:
Constant Field Values

messageRBjavac

private static java.util.ResourceBundle messageRBjavac

messageRBapt

private static java.util.ResourceBundle messageRBapt
Constructor Detail

Main

public Main(java.lang.String name)
Construct a compiler instance.


Main

public Main(java.lang.String name,
            java.io.PrintWriter out)
Construct a compiler instance.

Method Detail

help

void help()
Print a string that explains usage.


xhelp

void xhelp()
Print a string that explains usage for X options.


error

void error(java.lang.String key,
           java.lang.Object... args)
Report a usage error.


warning

void warning(java.lang.String key,
             java.lang.Object... args)
Report a warning.


processArgs

protected java.util.List<java.lang.String> processArgs(java.lang.String[] flags)
Process command line arguments: store all command line options in `options' table and return all source filenames.

Parameters:
args - The array of command line arguments.

compile

public int compile(java.lang.String[] args,
                   AnnotationProcessorFactory factory)
Programmatic interface for main function.

Parameters:
args - The command line parameters.

compile

int compile(java.lang.String[] args,
            Context context)
Programmatic interface for main function.

Parameters:
args - The command line parameters.

bugMessage

void bugMessage(java.lang.Throwable ex)
Print a message reporting an internal error.


apMessage

void apMessage(AnnotationProcessingError ex)
Print a message reporting an fatal error.


sceMessage

void sceMessage(sun.misc.ServiceConfigurationError ex)
Print a message about sun.misc.Service problem.


feMessage

void feMessage(java.lang.Throwable ex)
Print a message reporting an fatal error.


ioMessage

void ioMessage(java.lang.Throwable ex)
Print a message reporting an input/output error.


resourceMessage

void resourceMessage(java.lang.Throwable ex)
Print a message reporting an out-of-resources error.


getLocalizedString

private static java.lang.String getLocalizedString(java.lang.String key,
                                                   java.lang.Object... args)
Find a localized string in the resource bundle.

Parameters:
key - The key for the localized string.

initResource

private static void initResource()
Initialize ResourceBundle.


getText

private static java.lang.String getText(java.lang.String key,
                                        java.lang.Object... _args)
Get and format message string from resource.


pathToURLs

static java.net.URL[] pathToURLs(java.lang.String path)
Utility method for converting a search path string to an array of directory and JAR file URLs.

Parameters:
path - the search path string
Returns:
the resulting array of directory and JAR file URLs

fileToURL

static java.net.URL fileToURL(java.io.File file)
Returns the directory or JAR file URL corresponding to the specified local file name.

Parameters:
file - the File object
Returns:
the resulting directory or JAR file URL, or null if unknown