public class CheckerMain
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.regex.Pattern |
BOOT_CLASS_PATH_REGEX
A pattern to catch bootclasspath prepend entries, used to construct one -Xbootclasspath/p: argument
|
protected java.io.File |
checkersJar
The paths to the jar containing CheckerMain.class (i.e.
|
protected java.io.File |
javacJar
The path to the jsr308 Langtools Type Annotations Compiler
|
protected java.io.File |
jdkJar
The path to the annotated jdk jar to use
|
protected static java.util.regex.Pattern |
JVM_OPTS_REGEX
Matches all -J arguments
|
Constructor and Description |
---|
CheckerMain(java.io.File checkersJar,
java.lang.String[] args)
Construct all the relevant file locations and java version given the path to this jar and
a set of directories in which to search for jars
|
Modifier and Type | Method and Description |
---|---|
protected void |
addMainArgs(java.util.List<java.lang.String> args) |
protected void |
assertValidState() |
protected java.util.List<java.io.File> |
collectArgLists(java.util.List<java.lang.String> args)
Record (but don't remove) the arguments that start with @ and therefore
are files that contain javac arguments
|
protected java.util.List<java.lang.String> |
createCompilationBootclasspath(java.util.List<java.lang.String> argsList) |
protected java.util.List<java.lang.String> |
createCpOpts(java.util.List<java.lang.String> argsList) |
protected java.util.List<java.lang.String> |
createRuntimeBootclasspath(java.util.List<java.lang.String> argsList) |
protected static java.util.List<java.lang.String> |
expandArgs(java.util.List<java.io.File> args)
Iterate through the arguments and, for every argument that starts with an @, replace it
with the lines contained by that file.
|
protected static java.lang.String |
extractArg(java.lang.String argumentName,
java.lang.String alternative,
java.util.List<java.lang.String> args)
Remove the argument given by argumentName and the subsequent value from the list args if present.
|
protected static java.util.List<java.lang.String> |
extractBootClassPath(java.util.List<java.lang.String> args)
Remove all -Xbootclasspath/p: or -J-Xbootclasspath/p: arguments from args and add them to the returned list
|
protected static java.util.List<java.lang.String> |
extractCpOpts(java.util.List<java.lang.String> args)
Extract the -cp and -classpath arguments and there immediate predecessors in args.
|
protected static java.io.File |
extractFileArg(java.lang.String argumentName,
java.io.File alternative,
java.util.List<java.lang.String> args)
Remove the argument given by argumentName and the subsequent value from the list args if present.
|
protected static java.util.List<java.lang.String> |
extractJvmOpts(java.util.List<java.lang.String> args)
Remove all -J arguments from args and add them to the returned list
|
protected static java.util.List<java.lang.String> |
extractOptWPattern(java.util.regex.Pattern pattern,
boolean allowEmpties,
java.util.List<java.lang.String> args)
Find all args that match the given pattern and extract their index 1 group.
|
static java.lang.String |
findPathTo(java.lang.Class<?> context,
boolean directory)
Find the jar file or directory containing the .class file from which context was loaded
|
protected int |
invokeCompiler()
Invoke the JSR308 Type Annotations Compiler with all relevant jars on it's classpath or boot classpath
|
static void |
main(java.lang.String[] args)
Most logic of the CheckerMain main method is delegated to the CheckerMain class.
|
protected static java.lang.String |
prepFilePath(java.lang.String previous,
java.io.File... files)
Construct a file path from files nad prepend it to previous (if previous is not null)
|
protected final java.io.File jdkJar
protected final java.io.File javacJar
protected final java.io.File checkersJar
protected static final java.util.regex.Pattern BOOT_CLASS_PATH_REGEX
protected static final java.util.regex.Pattern JVM_OPTS_REGEX
public CheckerMain(java.io.File checkersJar, java.lang.String[] args)
public static void main(java.lang.String[] args)
args
- command-line arguments, eventually passed to the JSR 308 Type Annotations compilerprotected void assertValidState()
protected java.util.List<java.lang.String> createRuntimeBootclasspath(java.util.List<java.lang.String> argsList)
protected java.util.List<java.lang.String> createCompilationBootclasspath(java.util.List<java.lang.String> argsList)
protected java.util.List<java.lang.String> createCpOpts(java.util.List<java.lang.String> argsList)
protected java.util.List<java.io.File> collectArgLists(java.util.List<java.lang.String> args)
args
- A list of command line argumentsprotected static java.lang.String extractArg(java.lang.String argumentName, java.lang.String alternative, java.util.List<java.lang.String> args)
argumentName
- Argument to extractalternative
- Value to return if argumentName is not found in argsargs
- The current list of argumentsprotected static java.io.File extractFileArg(java.lang.String argumentName, java.io.File alternative, java.util.List<java.lang.String> args)
argumentName
- Argument to extractalternative
- File to return if argumentName is not found in argsargs
- The current list of argumentsprotected static java.lang.String prepFilePath(java.lang.String previous, java.io.File... files)
previous
- The previous file path to append to (can be null)files
- The files used to construct a path using File.pathSeparatorprotected static java.util.List<java.lang.String> extractOptWPattern(java.util.regex.Pattern pattern, boolean allowEmpties, java.util.List<java.lang.String> args)
pattern
- A pattern with at least one matching groupallowEmpties
- Whether or not to add empty group(1) matches to the returned listargs
- The arguments to extract fromprotected static java.util.List<java.lang.String> extractBootClassPath(java.util.List<java.lang.String> args)
args
- The arguments to extract fromprotected static java.util.List<java.lang.String> extractJvmOpts(java.util.List<java.lang.String> args)
args
- The arguments to extract fromprotected static java.util.List<java.lang.String> extractCpOpts(java.util.List<java.lang.String> args)
args
- A list of arguments to extract fromprotected void addMainArgs(java.util.List<java.lang.String> args)
protected int invokeCompiler()
protected static java.util.List<java.lang.String> expandArgs(java.util.List<java.io.File> args)
args
- A list of arguments, which may or may not be prefixed with an @public static java.lang.String findPathTo(java.lang.Class<?> context, boolean directory) throws java.lang.IllegalStateException
context
- The class whose .class file we wish to locatedirectory
- Whether to throw an exception if the file was loaded from a directoryjava.lang.IllegalStateException