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

public Class Arguments

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.file.Files, .Path, .Paths, java.util.Arrays, .Collections, .EnumSet, .HashSet, .Iterator, .LinkedHashMap, .LinkedHashSet, .Map, .Set, java.util.function.Predicate, java.util.regex.Matcher, .Pattern, java.util.stream.Stream, javax.lang.model.SourceVersion, javax.tools.JavaFileManager, .JavaFileManager.Location, .JavaFileObject, .JavaFileObject.Kind, .StandardJavaFileManager, .StandardLocation, com.sun.tools.doclint.DocLint, com.sun.tools.javac.code.Source, com.sun.tools.javac.file.BaseFileManager, .JavacFileManager, com.sun.tools.javac.jvm.Profile, .Target, com.sun.tools.javac.main.OptionHelper.GrumpyHelper, com.sun.tools.javac.platform.PlatformDescription, .PlatformUtils, com.sun.tools.javac.resources.CompilerProperties.Errors, .CompilerProperties.Fragments, .CompilerProperties.LintWarnings, .CompilerProperties.Warnings, com.sun.tools.javac.util.Context, .JCDiagnostic, .JCDiagnostic.DiagnosticInfo, .JCDiagnostic.Fragment, .List, .ListBuffer, .Log, .Log.PrefixKind, .Log.WriterKind, .Options, .PropagatedException

Shared option and argument handling for command line and API usage of javac.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static interface

Field Summary

Modifier and TypeField and Description
private final OptionHelper
public static final Context.Key<Arguments>
argsKey

The context key for the arguments.

private Set<String>
private final OptionHelper
private final Context
private Map<Option, String>
private boolean
private Arguments.ErrorMode
private boolean
private JavaFileManager
private Set<JavaFileObject>
private Set<Path>
private final Log
private final Options
private String

Constructor Summary

AccessConstructor and Description
protected
Arguments(Context context)

Method Summary

Modifier and TypeMethod and Description
public void
private boolean
pack-priv void
checkOptionAllowed(boolean allowed, Arguments.ErrorReporter r, Option... opts)

private boolean
doProcessArgs(Iterable<String> args, Set<Option> allowableOpts, OptionHelper helper, boolean allowOperands, boolean checkFileManager)

pack-priv void
public Set<String>

Returns:

the classes to be subject to annotation processing
getClassNames
()

Gets the classes to be subject to annotation processing.

public Map<Option, String>

Returns:

the deferred file manager options
getDeferredFileManagerOptions
()

Gets the file manager options which may have been deferred during processArgs.

public List<String>

Returns:

options for doclint
getDocLintOpts
()

Gets any options specifying how doclint should be run.

private JavaFileManager
public Set<JavaFileObject>

Returns:

the files to be compiled
getFileObjects
()

Gets the files to be compiled.

public Set<List<String>>

Returns:

options for plugins
getPluginOpts
()

Gets any options specifying plugins to be run.

public boolean

Returns:

true if successful, false otherwise
handleReleaseOptions
(Predicate<Iterable<String>>
a predicate to handle additional options implied by the --release option. The predicate should return true if all the additional options were processed successfully.
additionalOptions
)

Handles the --release option.

public void
init(String
the name of this tool; used to prefix messages
ownName
,
Iterable<String>
the args to be processed
args
)

Initializes this Args instance with a set of command line args.

public void
init(String
the name of this tool; used to prefix messages
ownName
,
Iterable<String>
the options to be processed
options
,
Iterable<String>
the classes to be subject to annotation processing
classNames
,
Iterable<? extends JavaFileObject>
the files to be compiled
files
)

Initializes this Args instance with the parameters for a JavacTask.

public void
init(String
the name of this tool; used to prefix messages
ownName
)

Minimal initialization for tools, like javadoc, to be able to process javac options for themselves, and then call validate.

public static Arguments

Returns:

the Arguments instance for this context.
instance
(Context
the content
context
)

Gets the Arguments instance for this context.

public boolean

Returns:

true if there are no files or classes specified for use
isEmpty
()

Returns true if there are no files or classes specified for use.

private boolean

Returns:

true if all the strings were successfully processed; false otherwise
processArgs
(Iterable<String>
the strings to be processed
args
,
Set<Option>
the set of option declarations that are applicable
allowableOpts
,
OptionHelper
a help for use by Option.process
helper
,
boolean
whether or not to check for files and classes
allowOperands
,
boolean
whether or not to check if the file manager can handle options which are not recognized by any of allowableOpts
checkFileManager
)

Processes strings containing options and operands.

private JCDiagnostic.Fragment
releaseNote(Source source, String targetString)

private void
pack-priv void
pack-priv <T> ListBuffer<T>
toList(Iterable<? extends T> items)

pack-priv <T> Set<T>
toSet(Iterable<? extends T> items)

public boolean

Returns:

true if all args are successfully validated; false otherwise.
validate
()

Validates the overall consistency of the options and operands processed by processOptions.

private void
private void
private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

apiHelperback to summary
private final OptionHelper apiHelper
argsKeyback to summary
public static final Context.Key<Arguments> argsKey

The context key for the arguments.

classNamesback to summary
private Set<String> classNames
cmdLineHelperback to summary
private final OptionHelper cmdLineHelper
contextback to summary
private final Context context
deferredFileManagerOptionsback to summary
private Map<Option, String> deferredFileManagerOptions
emptyAllowedback to summary
private boolean emptyAllowed
errorModeback to summary
private Arguments.ErrorMode errorMode
errorsback to summary
private boolean errors
fileManagerback to summary
private JavaFileManager fileManager
fileObjectsback to summary
private Set<JavaFileObject> fileObjects
filesback to summary
private Set<Path> files
logback to summary
private final Log log
optionsback to summary
private final Options options
ownNameback to summary
private String ownName

Constructor Detail

Argumentsback to summary
protected Arguments(Context context)
Annotations
@SuppressWarnings:this-escape

Method Detail

allowEmptyback to summary
public void allowEmpty()
checkDirectoryback to summary
private boolean checkDirectory(Option option)
checkOptionAllowedback to summary
pack-priv void checkOptionAllowed(boolean allowed, Arguments.ErrorReporter r, Option... opts)
doProcessArgsback to summary
private boolean doProcessArgs(Iterable<String> args, Set<Option> allowableOpts, OptionHelper helper, boolean allowOperands, boolean checkFileManager)
errorback to summary
pack-priv void error(Option.InvalidValueException f)
getClassNamesback to summary
public Set<String> getClassNames()

Gets the classes to be subject to annotation processing.

Returns:Set<String>

the classes to be subject to annotation processing

getDeferredFileManagerOptionsback to summary
public Map<Option, String> getDeferredFileManagerOptions()

Gets the file manager options which may have been deferred during processArgs.

Returns:Map<Option, String>

the deferred file manager options

getDocLintOptsback to summary
public List<String> getDocLintOpts()

Gets any options specifying how doclint should be run. An empty list is returned if no doclint options are specified or if the only doclint option is -Xdoclint:none.

Returns:List<String>

options for doclint

getFileManagerback to summary
private JavaFileManager getFileManager()
getFileObjectsback to summary
public Set<JavaFileObject> getFileObjects()

Gets the files to be compiled.

Returns:Set<JavaFileObject>

the files to be compiled

getPluginOptsback to summary
public Set<List<String>> getPluginOpts()

Gets any options specifying plugins to be run.

Returns:Set<List<String>>

options for plugins

handleReleaseOptionsback to summary
public boolean handleReleaseOptions(Predicate<Iterable<String>> additionalOptions)

Handles the --release option.

Parameters
additionalOptions:Predicate<Iterable<String>>

a predicate to handle additional options implied by the --release option. The predicate should return true if all the additional options were processed successfully.

Returns:boolean

true if successful, false otherwise

initback to summary
public void init(String ownName, Iterable<String> args)

Initializes this Args instance with a set of command line args. The args will be processed in conjunction with the full set of command line options, including -help, -version etc. The args may also contain class names and filenames. Any errors during this call, and later during validate, will be reported to the log.

Parameters
ownName:String

the name of this tool; used to prefix messages

args:Iterable<String>

the args to be processed

initback to summary
public void init(String ownName, Iterable<String> options, Iterable<String> classNames, Iterable<? extends JavaFileObject> files)

Initializes this Args instance with the parameters for a JavacTask. The options will be processed in conjunction with the restricted set of tool options, which does not include -help, -version, etc, nor does it include classes and filenames, which should be specified separately. File manager options are handled directly by the file manager. Any errors found while processing individual args will be reported via IllegalArgumentException. Any subsequent errors during validate will be reported via IllegalStateException.

Parameters
ownName:String

the name of this tool; used to prefix messages

options:Iterable<String>

the options to be processed

classNames:Iterable<String>

the classes to be subject to annotation processing

files:Iterable<? extends JavaFileObject>

the files to be compiled

initback to summary
public void init(String ownName)

Minimal initialization for tools, like javadoc, to be able to process javac options for themselves, and then call validate.

Parameters
ownName:String

the name of this tool; used to prefix messages

instanceback to summary
public static Arguments instance(Context context)

Gets the Arguments instance for this context.

Parameters
context:Context

the content

Returns:Arguments

the Arguments instance for this context.

isEmptyback to summary
public boolean isEmpty()

Returns true if there are no files or classes specified for use.

Returns:boolean

true if there are no files or classes specified for use

processArgsback to summary
private boolean processArgs(Iterable<String> args, Set<Option> allowableOpts, OptionHelper helper, boolean allowOperands, boolean checkFileManager)

Processes strings containing options and operands.

Parameters
args:Iterable<String>

the strings to be processed

allowableOpts:Set<Option>

the set of option declarations that are applicable

helper:OptionHelper

a help for use by Option.process

allowOperands:boolean

whether or not to check for files and classes

checkFileManager:boolean

whether or not to check if the file manager can handle options which are not recognized by any of allowableOpts

Returns:boolean

true if all the strings were successfully processed; false otherwise

Exceptions
IllegalArgumentException:
if a problem occurs and errorMode is set to ILLEGAL_ARGUMENT
releaseNoteback to summary
private JCDiagnostic.Fragment releaseNote(Source source, String targetString)
reportback to summary
private void report(JCDiagnostic.DiagnosticInfo diag)
reportDiagback to summary
pack-priv void reportDiag(JCDiagnostic.DiagnosticInfo diag)
toListback to summary
pack-priv <T> ListBuffer<T> toList(Iterable<? extends T> items)
toSetback to summary
pack-priv <T> Set<T> toSet(Iterable<? extends T> items)
validateback to summary
public boolean validate()

Validates the overall consistency of the options and operands processed by processOptions.

Returns:boolean

true if all args are successfully validated; false otherwise.

Exceptions
IllegalStateException:
if a problem is found and errorMode is set to ILLEGAL_STATE
validateAddExportsback to summary
private void validateAddExports(SourceVersion sv)
validateAddModulesback to summary
private void validateAddModules(SourceVersion sv)
validateAddReadsback to summary
private void validateAddReads(SourceVersion sv)
validateDefaultModuleForCreatedFilesback to summary
private void validateDefaultModuleForCreatedFiles(SourceVersion sv)
validateLimitModulesback to summary
private void validateLimitModules(SourceVersion sv)
com.sun.tools.javac.main back to summary

private final Enum Arguments.ErrorMode

extends Enum<Arguments.ErrorMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Arguments.ErrorMode
public static final Arguments.ErrorMode
public static final Arguments.ErrorMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Arguments.ErrorMode
public static Arguments.ErrorMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ILLEGAL_ARGUMENTback to summary
public static final Arguments.ErrorMode ILLEGAL_ARGUMENT
ILLEGAL_STATEback to summary
public static final Arguments.ErrorMode ILLEGAL_STATE
LOGback to summary
public static final Arguments.ErrorMode LOG

Constructor Detail

ErrorModeback to summary
private ErrorMode()

Method Detail

valueOfback to summary
public static Arguments.ErrorMode valueOf(String name)
valuesback to summary
public static Arguments.ErrorMode[] values()
com.sun.tools.javac.main back to summary

private Interface Arguments.ErrorReporter


Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

reportback to summary
public void report(Option o)