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 static String |
CHECKER_BASE_DIR_NAME |
protected static String |
CHECKER_BASE_PACKAGE
All "built-in" Checker Framework checkers, except SubtypingChecker, start with this package file path
Framework Checkers, except for SubtypingChecker are excluded from processor shorthand
|
protected File |
checkersJar
The paths to the jar containing CheckerMain.class (i.e.
|
protected static String |
FULLY_QUALIFIED_SUBTYPING_CHECKER |
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 static Pattern |
JVM_OPTS_REGEX
Matches all -J arguments
|
protected static String |
SUBTYPING_CHECKER_NAME |
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) |
void |
addToClasspath(List<String> cpOpts) |
void |
addToRuntimeBootclasspath(List<String> runtimeBootClasspathOpts) |
protected static String |
asCheckerFrameworkProcessors(String processorsString,
List<String> fullyQualifiedCheckerNames,
boolean allowSubcheckers)
Takes a processor string of the form
NullnessChecker
or
nullness
and returns:
org.checkerframework.checker.nullness.NullnessChecker
if the latter is found in the fullyQualifiedCheckerNames list.
|
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
|
List<String> |
getExecArguments()
Invoke the JSR308 Type Annotations Compiler with all relevant jars on it's classpath or boot classpath
|
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.
|
static boolean |
matchesCheckerOrSubcheckerFromList(String processorString,
List<String> fullyQualifiedCheckerNames) |
static boolean |
matchesFullyQualifiedProcessor(String processor,
List<String> fullyQualifiedCheckerNames,
boolean allowSubcheckers)
Takes a processor string of the form
"NullnessChecker"
or
"nullness"
and returns true
if it is found in the fullyQualifiedCheckerNames list.
|
protected static String |
prepFilePath(String previous,
File... files)
Construct a file path from files and prepend it to previous (if previous is not null)
|
protected void |
replaceShorthandProcessor(List<String> args)
For every "-processor" argument in args, replace its immediate successor argument using
asCheckerFrameworkProcessors
|
protected final File jdkJar
protected final File javacJar
protected final File checkersJar
protected static final Pattern BOOT_CLASS_PATH_REGEX
protected static final Pattern JVM_OPTS_REGEX
protected static final String CHECKER_BASE_PACKAGE
protected static final String CHECKER_BASE_DIR_NAME
protected static final String FULLY_QUALIFIED_SUBTYPING_CHECKER
protected static final String SUBTYPING_CHECKER_NAME
public static void main(String[] args)
args
- command-line arguments, eventually passed to the JSR 308 Type Annotations compilerprotected void assertValidState()
protected void replaceShorthandProcessor(List<String> args)
public void addToRuntimeBootclasspath(List<String> runtimeBootClasspathOpts)
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 frompublic List<String> getExecArguments()
public 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
public static boolean matchesCheckerOrSubcheckerFromList(String processorString, List<String> fullyQualifiedCheckerNames)
protected static String asCheckerFrameworkProcessors(String processorsString, List<String> fullyQualifiedCheckerNames, boolean allowSubcheckers)
processorsString
- A string identifying processorsfullyQualifiedCheckerNames
- A list of fully-qualified checker names to match processorsString against.allowSubcheckers
- Whether to match against fully qualified checker names ending with "Subchecker".public static boolean matchesFullyQualifiedProcessor(String processor, List<String> fullyQualifiedCheckerNames, boolean allowSubcheckers)
processor
- A string identifying one processor.fullyQualifiedCheckerNames
- A list of fully-qualified checker names to match processor against.allowSubcheckers
- Whether to match against fully qualified checker names ending with "Subchecker".