public class CheckerMain extends Object
To debug it, use the -AoutputArgsToFile=... command-line argument.
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
BOOT_CLASS_PATH_REGEX
A pattern to match 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.
|
protected File |
checkerJar
The path to the jar containing CheckerMain.class (i.e.
|
protected File |
checkerQualJar
The path to checker-qual.jar
|
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 checkerJar,
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 |
addToProcessorpath(List<String> ppOpts) |
void |
addToRuntimeBootclasspath(List<String> runtimeBootClasspathOpts) |
protected void |
assertValidState() |
protected List<File> |
collectArgFiles(List<String> args)
Return 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> |
createPpOpts(List<String> argsList) |
protected List<String> |
createRuntimeBootclasspath(List<String> argsList) |
protected static List<String> |
expandArgFiles(List<File> files)
Return all the lines in all the files.
|
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)
Remove the -cp and -classpath options and their arguments from 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> |
extractOptWithPattern(Pattern pattern,
boolean allowEmpties,
List<String> args)
Find all args that match the given pattern and extract their index 1 group.
|
protected static List<String> |
extractPpOpts(List<String> args)
Remove the -processorpath options and their arguments from args.
|
static String |
findPathTo(Class<?> cls,
boolean errIfFromDirectory)
Find the jar file or directory containing the .class file from which cls was loaded
|
List<String> |
getExecArguments()
Invoke the JSR308 Type Annotations Compiler with all relevant jars on its classpath or boot classpath
|
int |
invokeCompiler()
Invoke the JSR308 Type Annotations Compiler with all relevant jars on its classpath or boot classpath
|
static void |
main(String[] args)
Invoke the JSR 308 Type Annotations Compiler.
|
static boolean |
matchesCheckerOrSubcheckerFromList(String processorString,
List<String> fullyQualifiedCheckerNames)
Returns true if processorString, once transformed into
fully-qualified form, is present in fullyQualifiedCheckerNames.
|
static boolean |
matchesFullyQualifiedProcessor(String processor,
List<String> fullyQualifiedCheckerNames,
boolean allowSubcheckers)
Given a shorthand processor name, returns true if it can be expanded to a checker in the fullyQualifiedCheckerNames list.
|
protected void |
replaceShorthandProcessor(List<String> args)
For every "-processor" argument in args, replace its immediate successor argument using
unabbreviateProcessorNames
|
protected static String |
unshorthandProcessorNames(String processorsString,
List<String> fullyQualifiedCheckerNames,
boolean allowSubcheckers)
Takes a string of comma-separated processor names, and
expands any shorthands to fully-qualified names from the
fullyQualifiedCheckerNames list.
|
protected final File jdkJar
protected final File javacJar
protected final File checkerJar
protected final File checkerQualJar
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)
protected void assertValidState()
public void addToRuntimeBootclasspath(List<String> runtimeBootClasspathOpts)
protected List<String> createCompilationBootclasspath(List<String> argsList)
protected List<File> collectArgFiles(List<String> args)
args
- a list of command-line arguments; is not modifiedprotected static String extractArg(String argumentName, String alternative, List<String> args)
argumentName
- a command-line option name whose argument to extractalternative
- default value to return if argumentName does not appear 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 List<String> extractOptWithPattern(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 static List<String> extractPpOpts(List<String> args)
args
- a list of arguments to extract frompublic List<String> getExecArguments()
public int invokeCompiler()
protected static List<String> expandArgFiles(List<File> files)
files
- a list of filespublic static String findPathTo(Class<?> cls, boolean errIfFromDirectory) throws IllegalStateException
cls
- the class whose .class file we wish to locate; if null, CheckerMain.class.errIfFromDirectory
- If false, throw an exception if the file was loaded from a directoryIllegalStateException
public static boolean matchesCheckerOrSubcheckerFromList(String processorString, List<String> fullyQualifiedCheckerNames)
processorString
- the name of a single processor, not a comma-separated list of processorsfullyQualifiedCheckerNames
- a list of fully-qualified checker namesprotected void replaceShorthandProcessor(List<String> args)
protected static String unshorthandProcessorNames(String processorsString, List<String> fullyQualifiedCheckerNames, boolean allowSubcheckers)
NullnessChecker → org.checkerframework.checker.nullness.NullnessChecker nullness → org.checkerframework.checker.nullness.NullnessChecker NullnessChecker,RegexChecker → org.checkerframework.checker.nullness.NullnessChecker,org.checkerframework.checker.regex.RegexCheckerNote, a processor entry only gets replaced if it contains NO "." (i.e., it is not qualified by a package name) and can be found under the package org.checkerframework.checker in checker.jar.
processorsString
- a comma-separated string identifying processorsfullyQualifiedCheckerNames
- a list of fully-qualified checker names to match processorsString againstallowSubcheckers
- 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 processorfullyQualifiedCheckerNames
- a list of fully-qualified checker names to match processor againstallowSubcheckers
- whether to match against fully qualified checker names ending with "Subchecker"