public class CommandLineArgs extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
CommandLineArgs.ArgReader |
private static class |
CommandLineArgs.Prefix
Represent a single command line prefix
|
private static class |
CommandLineArgs.PrefixType
Argument types
|
Modifier and Type | Field and Description |
---|---|
private static int |
app_name_pos
The position of application class name.
|
private static CommandLineArgs.Prefix |
app_prefix
A catch-all prefix to find application name.
|
private static CommandLineArgs.PrefixType[] |
arg_types
The types of each command line argument.
|
private static String[] |
args
The command line arguments.
|
private static boolean |
DEBUG |
private static CommandLineArgs.Prefix[] |
prefixes
A list of possible prefixes for command line arguments.
|
Constructor and Description |
---|
CommandLineArgs() |
Modifier and Type | Method and Description |
---|---|
static void |
earlyProcessCommandLineArguments()
Stage1 processing of virtual machine directives appearing in argument list.
|
static void |
fetchCommandLineArguments()
Fetch arguments from program command line.
|
private static CommandLineArgs.Prefix |
findPrefix(CommandLineArgs.PrefixType type)
Find a Prefix object of a given type.
|
static String[] |
getArgs(CommandLineArgs.PrefixType prefix)
Extract all command line arguments of a particular type.
|
static String |
getBootstrapClasses()
Extract the classes that should go through bootstrap classloader.
|
private static String |
getCWD() |
static String |
getEnvironmentArg(String variable)
Extract the first -D... command line argument that matches a given
variable, and return it.
|
static String[] |
getEnvironmentArgs()
Get all environment arguments as pairs of string of key followed by value
|
static String[] |
getInputArgs() |
static String[] |
getJavaAgentArgs()
Extract command line arguments for the Java agent
|
private static String |
getOsArch() |
private static String |
getOsName() |
private static String |
getOsVersion() |
private static String |
getRvmRoot() |
private static String |
getUserHome() |
static String[] |
lateProcessCommandLineArguments()
Stage2 processing of virtual machine directives appearing in argument list.
|
private static int |
length(String p)
The real length of the prefix.
|
private static boolean |
matches(String arg,
String p)
Does the argument match the prefix?
|
static long |
parseMemorySize(String sizeName,
String sizeFlag,
String defaultFactor,
int roundTo,
String fullArg,
String subArg)
Primitive parsing of memory sizes, with proper error handling,
and so on.
|
static float |
primitiveParseFloat(String arg)
Primitive parsing of float/double values.
|
static int |
primitiveParseInt(String arg)
Primitive parsing of byte/integer numeric values.
|
private static byte[] |
s2b(String arg) |
private static byte[] |
stringToBytes(String argName,
String arg)
Convert the string s (the "argument") to a null-terminated byte array.
|
private static int |
sysArg(int argno,
byte[] buf)
Read the
argno 'th command line argument from the C argv |
private static final boolean DEBUG
private static final CommandLineArgs.Prefix app_prefix
private static final CommandLineArgs.Prefix[] prefixes
Prefixes are normally matched with the start of the argument. If the last character of the prefix is a '$', the prefix (without the trailing '$') will be matched with the whole argument. If the last character of the prefix is a ' ' (space), the prefix (without the trailing ' ') will be matched with the whole argument, and the next argument will be appended to the end of the one matching the prefix, with a space in between.
The type will be used to classify the prefix. Multiple entries CAN have the same type.
private static CommandLineArgs.PrefixType[] arg_types
private static int app_name_pos
public CommandLineArgs()
public static void fetchCommandLineArguments()
private static boolean matches(String arg, String p)
arg
- argumentp
- prefixprivate static int length(String p)
p
- prefixprivate static CommandLineArgs.Prefix findPrefix(CommandLineArgs.PrefixType type)
type
- given typenull
otherwisepublic static String[] getArgs(CommandLineArgs.PrefixType prefix)
prefix
- type of arguments to extractpublic static String[] getJavaAgentArgs()
public static String[] getEnvironmentArgs()
null
, if none were foundpublic static String getEnvironmentArg(String variable)
variable
- the non-null variable to matchpublic static String[] getInputArgs()
private static String getRvmRoot()
private static String getUserHome()
private static String getOsVersion()
public static String getBootstrapClasses()
public static void earlyProcessCommandLineArguments()
public static String[] lateProcessCommandLineArguments()
private static int sysArg(int argno, byte[] buf)
argno
'th command line argument from the C argvargno
- Number of argument soughtbuf
- Buffer to fillpublic static float primitiveParseFloat(String arg)
Double.valueOf
would require.
Does not support the full Java specification.arg
- the float value to parsepublic static int primitiveParseInt(String arg)
Byte.parseByte
or Integer.parseInt
.arg
- the int or byte value to parsepublic static long parseMemorySize(String sizeName, String sizeFlag, String defaultFactor, int roundTo, String fullArg, String subArg)
sizeName
- the option's namesizeFlag
- the flag's name, e.g. mx (as in "-Xmx")defaultFactor
- factor for modifying sizes, e.g. "K", "M" or "pages"roundTo
- round up to a multiple of this numberfullArg
- the full command line argument, e.g. "-Xmx200M"subArg
- the value for the argument, e.g. "200M"private static byte[] stringToBytes(String argName, String arg)
arg
- the argument to convertargName
- text to print for error reporting.arg
as a
null
-terminated C string. Returns null
for a null
arg.