Top Description Inners Fields Constructors Methods
com.sun.tools.javac.main

public Class Main

extends Object
Class Inheritance
Imports
java.io.FileNotFoundException, .IOException, .InputStream, .PrintWriter, .Writer, java.net.URL, java.nio.file.Files, .NoSuchFileException, .Path, .Paths, java.security.CodeSource, .DigestInputStream, .MessageDigest, .NoSuchAlgorithmException, java.text.SimpleDateFormat, java.util.Calendar, .Set, java.util.regex.Matcher, .Pattern, javax.tools.JavaFileManager, com.sun.tools.javac.api.BasicJavacTask, com.sun.tools.javac.file.CacheFSInfo, .BaseFileManager, .JavacFileManager, com.sun.tools.javac.jvm.Target, com.sun.tools.javac.platform.PlatformDescription, com.sun.tools.javac.processing.AnnotationProcessingError, com.sun.tools.javac.resources.CompilerProperties.Errors, com.sun.tools.javac.util.*, .JCDiagnostic.DiagnosticInfo, .Log.PrefixKind, .Log.WriterKind, jdk.internal.opt.CommandLine, .CommandLine.UnmatchedQuote

This class provides a command line interface to the javac compiler.

This is NOT part of any supported API. 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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Main.Result

Result codes.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
apiMode

If true, certain errors will cause an exception, such as command line arg errors, or exceptions in user provided code.

private static final String
private JavaFileManager
public static final String
public Log
log

The log to use for diagnostic output.

pack-priv String
ownName

The name of the compiler, for use in diagnostics.

pack-priv PrintWriter
stdErr

The writer to use for diagnostic output.

pack-priv PrintWriter
stdOut

The writer to use for normal output.

Constructor Summary

AccessConstructor and Description
public
Main(String
the name of this tool
name
)

Construct a compiler instance.

public
Main(String
the name of this tool
name
,
PrintWriter
a stream to which to write messages
out
)

Construct a compiler instance.

public
Main(String
the name of this tool
name
,
PrintWriter
a stream to which to write expected output
out
,
PrintWriter
a stream to which to write diagnostic output
err
)

Construct a compiler instance.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
apMessage(AnnotationProcessingError ex)

Print a message reporting an uncaught exception from an annotation processor.

pack-priv void
bugMessage(Throwable ex)

Print a message reporting an internal error.

public Main.Result

Returns:

the result of the compilation
compile
(String[]
the command line parameters
args
)

Programmatic interface for main function.

public Main.Result

Returns:

the result of the compilation
compile
(String[]
the command line parameters
argv
,
Context
the context
context
)

Internal version of compile, allowing context to be provided.

pack-priv void
feMessage(Throwable ex, Options options)

Print a message reporting a fatal error.

pack-priv void
ioMessage(Throwable ex)

Print a message reporting an input/output error.

pack-priv void
pluginMessage(Throwable ex)

Print a message reporting an uncaught exception from an annotation processor.

pack-priv void
pack-priv void
reportDiag(JCDiagnostic.DiagnosticInfo diag)

Report a usage error.

pack-priv void
pack-priv void
resourceMessage(Throwable ex)

Print a message reporting an out-of-resources error.

pack-priv void
showClass(String className)

Display the location and checksum of a class.

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

apiModeback to summary
pack-priv boolean apiMode

If true, certain errors will cause an exception, such as command line arg errors, or exceptions in user provided code.

ENV_OPT_NAMEback to summary
private static final String ENV_OPT_NAME
fileManagerback to summary
private JavaFileManager fileManager
javacBundleNameback to summary
public static final String javacBundleName
logback to summary
public Log log

The log to use for diagnostic output.

ownNameback to summary
pack-priv String ownName

The name of the compiler, for use in diagnostics.

stdErrback to summary
pack-priv PrintWriter stdErr

The writer to use for diagnostic output.

stdOutback to summary
pack-priv PrintWriter stdOut

The writer to use for normal output.

Constructor Detail

Mainback to summary
public Main(String name)

Construct a compiler instance.

Parameters
name:String

the name of this tool

Mainback to summary
public Main(String name, PrintWriter out)

Construct a compiler instance.

Parameters
name:String

the name of this tool

out:PrintWriter

a stream to which to write messages

Mainback to summary
public Main(String name, PrintWriter out, PrintWriter err)

Construct a compiler instance.

Parameters
name:String

the name of this tool

out:PrintWriter

a stream to which to write expected output

err:PrintWriter

a stream to which to write diagnostic output

Method Detail

apMessageback to summary
pack-priv void apMessage(AnnotationProcessingError ex)

Print a message reporting an uncaught exception from an annotation processor.

bugMessageback to summary
pack-priv void bugMessage(Throwable ex)

Print a message reporting an internal error.

compileback to summary
public Main.Result compile(String[] args)

Programmatic interface for main function.

Parameters
args:String[]

the command line parameters

Returns:Main.Result

the result of the compilation

compileback to summary
public Main.Result compile(String[] argv, Context context)

Internal version of compile, allowing context to be provided. Note that the context needs to have a file manager set up.

Parameters
argv:String[]

the command line parameters

context:Context

the context

Returns:Main.Result

the result of the compilation

feMessageback to summary
pack-priv void feMessage(Throwable ex, Options options)

Print a message reporting a fatal error.

ioMessageback to summary
pack-priv void ioMessage(Throwable ex)

Print a message reporting an input/output error.

pluginMessageback to summary
pack-priv void pluginMessage(Throwable ex)

Print a message reporting an uncaught exception from an annotation processor.

printArgumentsToFileback to summary
pack-priv void printArgumentsToFile(String... params)
reportDiagback to summary
pack-priv void reportDiag(JCDiagnostic.DiagnosticInfo diag)

Report a usage error.

reportHelperback to summary
pack-priv void reportHelper(JCDiagnostic.DiagnosticInfo diag)

Report helper.

resourceMessageback to summary
pack-priv void resourceMessage(Throwable ex)

Print a message reporting an out-of-resources error.

showClassback to summary
pack-priv void showClass(String className)

Display the location and checksum of a class.

twoClassLoadersInUseback to summary
private boolean twoClassLoadersInUse(IllegalAccessError iae)
com.sun.tools.javac.main back to summary

public final Enum Main.Result

extends Enum<Main.Result>
Class Inheritance

Result codes.

Field Summary

Modifier and TypeField and Description
public static final Main.Result
public static final Main.Result
public static final Main.Result
public final int
public static final Main.Result
public static final Main.Result

Constructor Summary

AccessConstructor and Description
private
Result(int exitCode)

Method Summary

Modifier and TypeMethod and Description
public boolean
isOK()

public static Main.Result
public static Main.Result[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ABNORMALback to summary
public static final Main.Result ABNORMAL
CMDERRback to summary
public static final Main.Result CMDERR
ERRORback to summary
public static final Main.Result ERROR
exitCodeback to summary
public final int exitCode
OKback to summary
public static final Main.Result OK
SYSERRback to summary
public static final Main.Result SYSERR

Constructor Detail

Resultback to summary
private Result(int exitCode)

Method Detail

isOKback to summary
public boolean isOK()
valueOfback to summary
public static Main.Result valueOf(String name)
valuesback to summary
public static Main.Result[] values()