public class PluginUtil
extends java.lang.Object
CheckerMain
.Modifier and Type | Class and Description |
---|---|
static class |
PluginUtil.CheckerProp |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHECKER_QUAL_PATH_OPT
Option name for specifying an alternative checker-qual.jar location.
|
static java.lang.String |
JAVAC_PATH_OPT
Option name for specifying an alternative javac.jar location.
|
static java.lang.String |
JDK_PATH_OPT
Option name for specifying an alternative jdk.jar location.
|
Constructor and Description |
---|
PluginUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
escapeQuotesAndSlashes(java.lang.String toEscape) |
static java.lang.String |
fileArgToStr(java.io.File fileArg) |
static java.util.List<java.lang.String> |
getBooleanProp(java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props,
PluginUtil.CheckerProp prop,
java.lang.String cmdLineArg)
If prop is in props, return a 1-element list containing
cmdLineArg . |
static boolean |
getBooleanSystemProperty(java.lang.String key)
Return true if the system property is set to "true".
|
static boolean |
getBooleanSystemProperty(java.lang.String key,
boolean defaultValue)
Return its boolean value if the system property is set.
|
static java.util.List<java.lang.String> |
getCmd(java.lang.String executable,
java.io.File javacPath,
java.io.File jdkPath,
java.io.File srcFofn,
java.lang.String processors,
java.lang.String checkerHome,
java.lang.String javaHome,
java.io.File classPathFofn,
java.lang.String bootClassPath,
java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props,
java.io.PrintStream out,
boolean procOnly,
java.lang.String outputDirectory) |
static java.util.List<java.lang.String> |
getCmdArgsOnly(java.io.File javacPath,
java.io.File jdkPath,
java.io.File srcFofn,
java.lang.String processors,
java.lang.String checkerHome,
java.lang.String javaHome,
java.io.File classpathFofn,
java.lang.String bootClassPath,
java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props,
java.io.PrintStream out,
boolean procOnly,
java.lang.String outputDirectory) |
static java.util.List<java.lang.String> |
getCmdArgsOnly(java.io.File srcFofn,
java.lang.String processors,
java.lang.String checkerHome,
java.lang.String javaHome,
java.io.File classpathFofn,
java.lang.String bootClassPath,
java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props,
java.io.PrintStream out,
boolean procOnly,
java.lang.String outputDirectory) |
static java.lang.String |
getJavaCommand(java.lang.String javaHome,
java.io.PrintStream out) |
static java.lang.String |
getJdkJarName()
Determine the version of the JRE that we are currently running and select a jdkX.jar where X
is the version of Java that is being run (e.g.
|
static java.lang.String |
getJdkJarPrefix()
Determine the version of the JRE that we are currently running and select a jdkX where X is
the version of Java that is being run (e.g.
|
static int |
getJreVersion()
Extract the major version number from java.version.
|
static java.util.List<java.lang.String> |
getStringProp(java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props,
PluginUtil.CheckerProp prop,
java.lang.String cmdLineArgStart,
java.lang.String... extras)
Returns a list of command-line arguments: one that sets the given property, plus everything
in extras.
|
static boolean |
isWindows() |
static java.lang.String |
join(java.lang.String delimiter,
java.lang.Iterable<?> values) |
static <T> java.lang.String |
join(java.lang.String delimiter,
T[] objs) |
static java.util.List<java.lang.String> |
readFile(java.io.File argFile)
Return a list of Strings, one per line of the file.
|
static java.util.List<java.io.File> |
toFiles(java.util.List<java.lang.String> fileNames) |
static java.util.List<java.lang.String> |
toJavaOpts(java.util.List<java.lang.String> opts) |
static java.lang.String |
wrapArg(java.lang.String classpath) |
static void |
writeFile(java.io.File destination,
java.util.List<java.lang.String> contents)
Write the strings to the file, one per line.
|
static void |
writeFofn(java.io.File destination,
java.io.File... files)
Takes a list of files and writes it as a "File of file names" (i.e.
|
static void |
writeFofn(java.io.File destination,
java.util.List<java.io.File> files)
Takes a list of files and writes it as a "File of file names" (i.e.
|
static java.io.File |
writeTmpCpFile(java.lang.String prefix,
boolean deleteOnExit,
java.lang.String classpath) |
static java.io.File |
writeTmpFile(java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit,
java.util.List<java.lang.String> args)
Write the strings to a temporary file.
|
static java.io.File |
writeTmpFofn(java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit,
java.util.List<java.io.File> files) |
static java.io.File |
writeTmpSrcFofn(java.lang.String prefix,
boolean deleteOnExit,
java.util.List<java.io.File> files) |
public static final java.lang.String CHECKER_QUAL_PATH_OPT
public static final java.lang.String JAVAC_PATH_OPT
public static final java.lang.String JDK_PATH_OPT
public static java.util.List<java.io.File> toFiles(java.util.List<java.lang.String> fileNames)
public static void writeFofn(java.io.File destination, java.util.List<java.io.File> files) throws java.io.IOException
destination
- the fofn file we are writing. This file will contain newline separated
list of absolute file paths.files
- the files to write to the destination filejava.io.IOException
public static void writeFofn(java.io.File destination, java.io.File... files) throws java.io.IOException
destination
- the fofn file we are writing. This file will contain newline separated
list of absolute file paths.files
- the files to write to the destination filejava.io.IOException
public static java.io.File writeTmpFofn(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit, java.util.List<java.io.File> files) throws java.io.IOException
java.io.IOException
public static java.io.File writeTmpFile(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit, java.util.List<java.lang.String> args) throws java.io.IOException
deleteOnExit
- if true, delete the file on program exitjava.io.IOException
public static void writeFile(java.io.File destination, java.util.List<java.lang.String> contents) throws java.io.IOException
java.io.IOException
public static java.util.List<java.lang.String> readFile(java.io.File argFile) throws java.io.IOException
java.io.IOException
public static <T> java.lang.String join(java.lang.String delimiter, T[] objs)
public static java.lang.String join(java.lang.String delimiter, java.lang.Iterable<?> values)
public static java.util.List<java.lang.String> getStringProp(java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props, PluginUtil.CheckerProp prop, java.lang.String cmdLineArgStart, java.lang.String... extras)
prop
- the property to look up in propscmdLineArgStart
- the command-line argument that introduces proppublic static java.util.List<java.lang.String> getBooleanProp(java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props, PluginUtil.CheckerProp prop, java.lang.String cmdLineArg)
cmdLineArg
. Otherwise, return
a 0-element list.public static boolean getBooleanSystemProperty(java.lang.String key)
public static boolean getBooleanSystemProperty(java.lang.String key, boolean defaultValue)
public static java.io.File writeTmpSrcFofn(java.lang.String prefix, boolean deleteOnExit, java.util.List<java.io.File> files) throws java.io.IOException
java.io.IOException
public static java.io.File writeTmpCpFile(java.lang.String prefix, boolean deleteOnExit, java.lang.String classpath) throws java.io.IOException
java.io.IOException
public static boolean isWindows()
public static java.lang.String wrapArg(java.lang.String classpath)
public static java.lang.String escapeQuotesAndSlashes(java.lang.String toEscape)
public static java.lang.String getJavaCommand(java.lang.String javaHome, java.io.PrintStream out)
public static java.lang.String fileArgToStr(java.io.File fileArg)
public static java.util.List<java.lang.String> getCmd(java.lang.String executable, java.io.File javacPath, java.io.File jdkPath, java.io.File srcFofn, java.lang.String processors, java.lang.String checkerHome, java.lang.String javaHome, java.io.File classPathFofn, java.lang.String bootClassPath, java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props, java.io.PrintStream out, boolean procOnly, java.lang.String outputDirectory)
public static java.util.List<java.lang.String> toJavaOpts(java.util.List<java.lang.String> opts)
public static java.util.List<java.lang.String> getCmdArgsOnly(java.io.File srcFofn, java.lang.String processors, java.lang.String checkerHome, java.lang.String javaHome, java.io.File classpathFofn, java.lang.String bootClassPath, java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props, java.io.PrintStream out, boolean procOnly, java.lang.String outputDirectory)
public static java.util.List<java.lang.String> getCmdArgsOnly(java.io.File javacPath, java.io.File jdkPath, java.io.File srcFofn, java.lang.String processors, java.lang.String checkerHome, java.lang.String javaHome, java.io.File classpathFofn, java.lang.String bootClassPath, java.util.Map<PluginUtil.CheckerProp,java.lang.Object> props, java.io.PrintStream out, boolean procOnly, java.lang.String outputDirectory)
public static int getJreVersion()
public static java.lang.String getJdkJarPrefix()
public static java.lang.String getJdkJarName()