public class CheckerMain extends Object
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
BOOT_CLASS_PATH_REGEX
A pattern to catch bootclasspath prepend entries, used to construct one -Xbootclasspath/p: argument
|
protected File |
checkersJar
The paths to the jar containing CheckerMain.class (i.e.
|
protected File |
javacJar
The path to the jsr308 Langtools Type Annotations Compiler
|
protected File |
jdkJar
The path to the annotated jdk jar to use
|
protected double |
jreVersion
The current major version of the jre in the form 1.X where X is the major version of Java
|
protected static Pattern |
JVM_OPTS_REGEX
Matches all -J arguments
|
Constructor and Description |
---|
CheckerMain(File checkersJar,
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(List<String> args) |
protected void |
assertValidState() |
protected List<File> |
collectArgLists(List<String> args)
Record (but don't remove) the arguments that start with @ and therefore
are files that contain javac arguments
|
protected List<String> |
createCompilationBootclasspath(List<String> argsList) |
protected List<String> |
createCpOpts(List<String> argsList) |
protected List<String> |
createRuntimeBootclasspath(List<String> argsList) |
protected static List<String> |
expandArgs(List<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 String |
extractArg(String argumentName,
String alternative,
List<String> args)
Remove the argument given by argumentName and the subsequent value from the list args if present.
|
protected static List<String> |
extractBootClassPath(List<String> args)
Remove all -Xbootclasspath/p: or -J-Xbootclasspath/p: arguments from args and add them to the returned list
|
protected static List<String> |
extractCpOpts(List<String> args)
Extract the -cp and -classpath arguments and there immediate predecessors in args.
|
protected static File |
extractFileArg(String argumentName,
File alternative,
List<String> args)
Remove the argument given by argumentName and the subsequent value from the list args if present.
|
protected static List<String> |
extractJvmOpts(List<String> args)
Remove all -J arguments from args and add them to the returned list
|
protected static List<String> |
extractOptWPattern(Pattern pattern,
boolean allowEmpties,
List<String> args)
Find all args that match the given pattern and extract their index 1 group.
|
static String |
findPathTo(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(String[] args)
Most logic of the CheckerMain main method is delegated to the CheckerMain class.
|
protected static String |
prepFilePath(String previous,
File... files)
Construct a file path from files nad prepend it to previous (if previous is not null)
|
protected final File jdkJar
protected final File javacJar
protected final File checkersJar
protected final double jreVersion
protected static final Pattern BOOT_CLASS_PATH_REGEX
protected static final Pattern JVM_OPTS_REGEX
public static void main(String[] args)
args
- Command line arguments, eventually passed to the jsr308 type annotations compilerException
- Any exception thrown by the Checker Framework escape to the command lineprotected void assertValidState()
protected List<String> createCompilationBootclasspath(List<String> argsList)
protected List<File> collectArgLists(List<String> args)
args
- A list of command line argumentsprotected static String extractArg(String argumentName, String alternative, List<String> args)
argumentName
- Argument to extractalternative
- Value to return if argumentName is not found in argsargs
- The current list of argumentsprotected static File extractFileArg(String argumentName, File alternative, List<String> args)
argumentName
- Argument to extractalternative
- File to return if argumentName is not found in argsargs
- The current list of argumentsprotected static String prepFilePath(String previous, 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 List<String> extractOptWPattern(Pattern pattern, boolean allowEmpties, List<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 List<String> extractBootClassPath(List<String> args)
args
- The arguments to extract fromprotected static List<String> extractJvmOpts(List<String> args)
args
- The arguments to extract fromprotected static List<String> extractCpOpts(List<String> args)
args
- A list of arguments to extract fromprotected int invokeCompiler()
protected static List<String> expandArgs(List<File> args)
args
- A list of arguments, which may or may not be prefixed with an @public static String findPathTo(Class<?> context, boolean directory) throws IllegalStateException
context
- The class whose .class file we wish to locatedirectory
- Whether to throw an exception if the file was loaded from a directoryIllegalStateException