com.sun.tools.javac.main
Class Main

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

public class Main
extends java.lang.Object

This class provides a commandline interface to the GJC compiler.

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.


Field Summary
 ListBuffer<java.lang.String> classnames
          List of class files names passed on the command line
(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)  boolean fatalErrors
          If true, any command line arg errors will cause an exception.
private  JavaFileManager fileManager
           
 ListBuffer<java.io.File> filenames
          The list of source files to process
private static java.lang.String javacBundleName
           
private static JavacMessages messages
           
private  Options options
          A table of all options that's passed to the JavaCompiler constructor.
(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.
private  JavacOption.Option[] recognizedOptions
           
 
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 uncaught exception from an annotation processor.
(package private)  void bugMessage(java.lang.Throwable ex)
          Print a message reporting an internal error.
private  boolean checkDirectory(java.lang.String optName)
           
 int compile(java.lang.String[] args)
          Programmatic interface for main function.
 int compile(java.lang.String[] args, Context context)
           
 int compile(java.lang.String[] args, Context context, List<JavaFileObject> fileObjects, java.lang.Iterable<? extends Processor> processors)
          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.
static java.lang.String getLocalizedString(java.lang.String key, java.lang.Object... args)
          Find a localized string in the resource bundle.
 JavacOption.Option getOption(java.lang.String flag)
           
(package private)  void help()
          Print a string that explains usage.
(package private)  void ioMessage(java.lang.Throwable ex)
          Print a message reporting an input/output error.
 List<java.io.File> 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.
 void setFatalErrors(boolean fatalErrors)
           
 void setOptions(Options options)
           
static void useRawMessages(boolean enable)
           
(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

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.


fatalErrors

boolean fatalErrors
If true, any command line arg errors will cause an exception.


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 JavacOption.Option[] recognizedOptions

options

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


filenames

public ListBuffer<java.io.File> filenames
The list of source files to process


classnames

public ListBuffer<java.lang.String> classnames
List of class files names passed on the command line


fileManager

private JavaFileManager fileManager

javacBundleName

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

messages

private static JavacMessages messages
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.


getOption

public JavacOption.Option getOption(java.lang.String flag)

setOptions

public void setOptions(Options options)

setFatalErrors

public void setFatalErrors(boolean fatalErrors)

processArgs

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

Parameters:
flags - The array of command line arguments.

checkDirectory

private boolean checkDirectory(java.lang.String optName)

compile

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

Parameters:
args - The command line parameters.

compile

public int compile(java.lang.String[] args,
                   Context context)

compile

public int compile(java.lang.String[] args,
                   Context context,
                   List<JavaFileObject> fileObjects,
                   java.lang.Iterable<? extends Processor> processors)
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.


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.


apMessage

void apMessage(AnnotationProcessingError ex)
Print a message reporting an uncaught exception from an annotation processor.


getLocalizedString

public 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.

useRawMessages

public static void useRawMessages(boolean enable)