test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java Fri Nov 6 09:35:37 2015
--- new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java Fri Nov 6 09:35:37 2015
*** 35,44 ****
--- 35,45 ----
import java.util.StringTokenizer;
import java.util.function.Predicate;
import jdk.test.lib.OutputAnalyzer;
import jdk.test.lib.Platform;
import jdk.test.lib.ProcessTools;
+ import java.math.BigDecimal;
public class JVMOptionsUtils {
/* Java option which print options with ranges */
private static final String PRINT_FLAGS_RANGES = "-XX:+PrintFlagsRanges";
*** 47,56 ****
--- 48,59 ----
private static final StringBuilder finalFailedMessage = new StringBuilder();
/* Used to start the JVM with the same type as current */
static String VMType;
+ private static Map<String, JVMOption> optionsAsMap;
+
static {
if (Platform.isServer()) {
VMType = "-server";
} else if (Platform.isClient()) {
VMType = "-client";
*** 61,70 ****
--- 64,151 ----
} else {
VMType = null;
}
}
+ public static boolean fitsRange(String optionName, BigDecimal number) throws Exception {
+ JVMOption option;
+ String minRangeString = null;
+ String maxRangeString = null;
+ boolean fits = true;
+
+ if (optionsAsMap == null) {
+ optionsAsMap = getOptionsWithRangeAsMap();
+ }
+
+ option = optionsAsMap.get(optionName);
+ if (option != null) {
+ minRangeString = option.getMin();
+ if (minRangeString != null) {
+ fits = (number.compareTo(new BigDecimal(minRangeString)) >= 0);
+ }
+ maxRangeString = option.getMax();
+ if (maxRangeString != null) {
+ fits &= (number.compareTo(new BigDecimal(maxRangeString)) <= 0);
+ }
+ }
+
+ return fits;
+ }
+
+ public static boolean fitsRange(String optionName, String number) throws Exception {
+ String lowerCase = number.toLowerCase();
+ String multiplier = "1";
+ if (lowerCase.endsWith("k")) {
+ multiplier = "1024";
+ lowerCase = lowerCase.substring(0, lowerCase.length()-1);
+ } else if (lowerCase.endsWith("m")) {
+ multiplier = "1048576";//1024*1024
+ lowerCase = lowerCase.substring(0, lowerCase.length()-1);
+ } else if (lowerCase.endsWith("g")) {
+ multiplier = "1073741824";//1024*1024*1024
+ lowerCase = lowerCase.substring(0, lowerCase.length()-1);
+ } else if (lowerCase.endsWith("t")) {
+ multiplier = "1099511627776";//1024*1024*1024*1024
+ lowerCase = lowerCase.substring(0, lowerCase.length()-1);
+ }
+ BigDecimal valueBig = new BigDecimal(lowerCase);
+ BigDecimal multiplierBig = new BigDecimal(multiplier);
+ return fitsRange(optionName, valueBig.multiply(multiplierBig));
+ }
+
+ public static String getMinOptionRange(String optionName) throws Exception {
+ JVMOption option;
+ String minRange = null;
+
+ if (optionsAsMap == null) {
+ optionsAsMap = getOptionsWithRangeAsMap();
+ }
+
+ option = optionsAsMap.get(optionName);
+ if (option != null) {
+ minRange = option.getMin();
+ }
+
+ return minRange;
+ }
+
+ public static String getMaxOptionRange(String optionName) throws Exception {
+ JVMOption option;
+ String maxRange = null;
+
+ if (optionsAsMap == null) {
+ optionsAsMap = getOptionsWithRangeAsMap();
+ }
+
+ option = optionsAsMap.get(optionName);
+ if (option != null) {
+ maxRange = option.getMax();
+ }
+
+ return maxRange;
+ }
+
/**
* Add dependency for option depending on it's name. E.g. enable G1 GC for
* G1 options or add prepend options to not hit constraints.
*
* @param option option
test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File