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