39 } |
39 } |
40 |
40 |
41 /** |
41 /** |
42 * Returns true if {@code arg} is an input argument to the VM. |
42 * Returns true if {@code arg} is an input argument to the VM. |
43 * |
43 * |
|
44 * This is useful for checking boolean flags such as -XX:+UseSerialGC or |
|
45 * -XX:-UsePerfData. |
|
46 * |
44 * @param arg The name of the argument. |
47 * @param arg The name of the argument. |
45 * @return {@code true} if the given argument is an input argument, |
48 * @return {@code true} if the given argument is an input argument, |
46 * otherwise {@code false}. |
49 * otherwise {@code false}. |
47 */ |
50 */ |
48 public static boolean contains(String arg) { |
51 public static boolean contains(String arg) { |
49 return args.contains(arg); |
52 return args.contains(arg); |
50 } |
53 } |
|
54 |
|
55 /** |
|
56 * Returns true if {@code prefix} is the start of an input argument to the |
|
57 * VM. |
|
58 * |
|
59 * This is useful for checking if flags describing a quantity, such as |
|
60 * -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity. |
|
61 * To check if the flag -XX:MaxMetaspaceSize is set, use |
|
62 * {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}. |
|
63 * |
|
64 * @param prefix The start of the argument. |
|
65 * @return {@code true} if the given argument is the start of an input |
|
66 * argument, otherwise {@code false}. |
|
67 */ |
|
68 public static boolean containsPrefix(String prefix) { |
|
69 for (String arg : args) { |
|
70 if (arg.startsWith(prefix)) { |
|
71 return true; |
|
72 } |
|
73 } |
|
74 return false; |
|
75 } |
51 } |
76 } |