--- old/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java 2015-06-16 18:41:17.745576519 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java 2015-06-16 18:41:17.641576518 +0300 @@ -27,6 +27,9 @@ * value which is not allowed by constraint. Also check that * jcmd does not print an error message to the target process output. * @library /testlibrary + * @modules java.base/sun.misc + * java.management + * jdk.management * @run main TestJcmdOutput */ --- old/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2015-06-16 18:41:18.213576520 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java 2015-06-16 18:41:18.101576520 +0300 @@ -25,6 +25,10 @@ * @test * @summary Test VM Options with ranges * @library /testlibrary /runtime/CommandLine/OptionsValidation/common + * @modules java.base/sun.misc + * java.management + * jdk.attach + * jdk.management/sun.tools.attach * @run main/othervm/timeout=600 TestOptionsWithRanges */ @@ -37,51 +41,23 @@ public class TestOptionsWithRanges { - static List optionsToTest = new ArrayList<>(); - static Map allOptionsAsMap; - - private static void addOptionToTest(String name) { - JVMOption toAdd = allOptionsAsMap.get(name); - if (toAdd != null) { - optionsToTest.add(toAdd); - } else { - System.out.println("Option with name \"" + name + "\" not found in "+ - "the list of options with ranges. Thus not test this option."); - } - } - public static void main(String[] args) throws Exception { int failedTests; - - allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(); + Map allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(); + List allOptions; + + /* + * Remove CICompilerCount from testing because currently it can hang system + */ + allOptionsAsMap.remove("CICompilerCount"); - /* Add several intx options to test */ - addOptionToTest("AllocatePrefetchStyle"); - addOptionToTest("CMSInitiatingOccupancyFraction"); - addOptionToTest("CMSTriggerInterval"); - addOptionToTest("PerBytecodeRecompilationCutoff"); - addOptionToTest("G1RefProcDrainInterval"); - addOptionToTest("BlockLayoutMinDiamondPercentage"); - addOptionToTest("ValueMapInitialSize"); - /* Add several uintx options to test */ - addOptionToTest("StringDeduplicationAgeThreshold"); - addOptionToTest("AdaptiveSizeDecrementScaleFactor"); - addOptionToTest("CMSPrecleanNumerator"); - addOptionToTest("IncreaseFirstTierCompileThresholdAt"); - /* Add several size_t options to test */ - addOptionToTest("CompressedClassSpaceSize"); - addOptionToTest("HeapSizePerGCThread"); - addOptionToTest("G1ConcRSLogCacheSize"); - /* Add double option to test */ - addOptionToTest("G1ConcMarkStepDurationMillis"); - /* Add uint64_t option to test */ - addOptionToTest("MaxRAM"); + allOptions = new ArrayList<>(allOptionsAsMap.values()); - Asserts.assertGT(optionsToTest.size(), 0, "Options with ranges not found!"); + Asserts.assertGT(allOptions.size(), 0, "Options with ranges not found!"); - System.out.println("Test " + optionsToTest.size() + " options with ranges. Start test!"); + System.out.println("Parsed " + allOptions.size() + " options with ranges. Start test!"); - failedTests = JVMOptionsUtils.runCommandLineTests(optionsToTest); + failedTests = JVMOptionsUtils.runCommandLineTests(allOptions); Asserts.assertEQ(failedTests, 0, String.format("%d tests failed! %s", failedTests, JVMOptionsUtils.getMessageWithFailures())); --- old/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRangesDynamic.java 2015-06-16 18:41:18.637576522 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRangesDynamic.java 2015-06-16 18:41:18.521576521 +0300 @@ -25,6 +25,10 @@ * @test * @summary Test writeable VM Options with ranges. * @library /testlibrary /runtime/CommandLine/OptionsValidation/common + * @modules java.base/sun.misc + * java.management + * jdk.attach + * jdk.management/sun.tools.attach * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestOptionsWithRangesDynamic */ @@ -44,7 +48,7 @@ Asserts.assertGT(allWriteableOptions.size(), 0, "Options with ranges not found!"); - System.out.println("Parsed " + allWriteableOptions.size() + " writeable options with ranges. Start test!"); + System.out.println("Test " + allWriteableOptions.size() + " writeable options with ranges. Start test!"); failedTests = JVMOptionsUtils.runDynamicTests(allWriteableOptions); --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java 2015-06-16 18:41:19.065576523 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java 2015-06-16 18:41:18.941576523 +0300 @@ -51,6 +51,8 @@ */ DoubleJVMOption(String name) { this.name = name; + min = Double.MIN_VALUE; + max = Double.MAX_VALUE; } /** @@ -83,7 +85,7 @@ */ @Override String getMin() { - return String.format("%f", min); + return formatValue(min); } /** @@ -103,9 +105,13 @@ */ @Override String getMax() { - return String.format("%f", max); + return formatValue(max); } - + + private String formatValue(double value) { + return String.format("%f", value); + } + /** * Return list of strings with valid option values which used for testing * using jcmd, attach and etc. @@ -116,22 +122,22 @@ protected List getValidValues() { List validValues = new ArrayList<>(); - validValues.add(String.format("%f", min)); - validValues.add(String.format("%f", max)); + validValues.add(formatValue(min)); + validValues.add(formatValue(max)); if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_NEGATIVE) < 0) && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_NEGATIVE) > 0)) { - validValues.add(String.format("%f", ADDITIONAL_TEST_DOUBLE_NEGATIVE)); + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_NEGATIVE)); } if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_ZERO) < 0) && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_ZERO) > 0)) { - validValues.add(String.format("%f", ADDITIONAL_TEST_DOUBLE_ZERO)); + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_ZERO)); } if ((Double.compare(min, ADDITIONAL_TEST_DOUBLE_POSITIVE) < 0) && (Double.compare(max, ADDITIONAL_TEST_DOUBLE_POSITIVE) > 0)) { - validValues.add(String.format("%f", ADDITIONAL_TEST_DOUBLE_POSITIVE)); + validValues.add(formatValue(ADDITIONAL_TEST_DOUBLE_POSITIVE)); } return validValues; @@ -147,23 +153,26 @@ protected List getInvalidValues() { List invalidValues = new ArrayList<>(); - if (Double.compare(min, Double.MIN_VALUE) != 0) { - if ((Double.compare(min, 0.0) > 0) - && (Double.isNaN(min * 0.999) == false)) { - invalidValues.add(String.format("%f", min * 0.999)); - } else if ((Double.compare(min, 0.0) < 0) - && (Double.isNaN(min * 1.001) == false)) { - invalidValues.add(String.format("%f", min * 1.001)); + if (withRange) { + /* Return invalid values only for options which have defined range in VM */ + if (Double.compare(min, Double.MIN_VALUE) != 0) { + if ((Double.compare(min, 0.0) > 0) + && (Double.isNaN(min * 0.999) == false)) { + invalidValues.add(formatValue(min * 0.999)); + } else if ((Double.compare(min, 0.0) < 0) + && (Double.isNaN(min * 1.001) == false)) { + invalidValues.add(formatValue(min * 1.001)); + } } - } - if (Double.compare(max, Double.MAX_VALUE) != 0) { - if ((Double.compare(max, 0.0) > 0) - && (Double.isNaN(max * 1.001) == false)) { - invalidValues.add(String.format("%f", max * 1.001)); - } else if ((Double.compare(max, 0.0) < 0) - && (Double.isNaN(max * 0.999) == false)) { - invalidValues.add(String.format("%f", max * 0.999)); + if (Double.compare(max, Double.MAX_VALUE) != 0) { + if ((Double.compare(max, 0.0) > 0) + && (Double.isNaN(max * 1.001) == false)) { + invalidValues.add(formatValue(max * 1.001)); + } else if ((Double.compare(max, 0.0) < 0) + && (Double.isNaN(max * 0.999) == false)) { + invalidValues.add(formatValue(max * 0.999)); + } } } --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/IntJVMOption.java 2015-06-16 18:41:19.513576524 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/IntJVMOption.java 2015-06-16 18:41:19.377576524 +0300 @@ -35,13 +35,18 @@ private static final BigInteger MAX_UNSIGNED_LONG; private static final BigInteger MAX_UNSIGNED_LONG_64; private static final BigInteger MINUS_ONE = new BigInteger("-1"); + private static final BigInteger TWO = new BigInteger("2"); + private static final BigInteger MIN_4_BYTE_INT = new BigInteger("-2147483648"); + private static final BigInteger MAX_4_BYTE_INT = new BigInteger("2147483647"); private static final BigInteger MAX_4_BYTE_INT_PLUS_ONE = new BigInteger("2147483648"); + private static final BigInteger MAX_4_BYTE_UNSIGNED_INT = new BigInteger("4294967295"); private static final BigInteger MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE = new BigInteger("4294967296"); /** * Mininum option value */ private BigInteger min; + /** * Maximum option value */ @@ -58,6 +63,11 @@ private boolean unsigned; /** + * Is this 32 bit type + */ + private boolean is32Bit = false; + + /** * Is this value 64 bit unsigned */ private boolean uint64 = false; @@ -66,15 +76,15 @@ if (Platform.is32bit()) { MIN_LONG = new BigInteger(String.valueOf(Integer.MIN_VALUE)); MAX_LONG = new BigInteger(String.valueOf(Integer.MAX_VALUE)); - MAX_UNSIGNED_LONG = MAX_LONG.multiply(new BigInteger("2")).add(BigInteger.ONE); + MAX_UNSIGNED_LONG = MAX_LONG.multiply(TWO).add(BigInteger.ONE); } else { MIN_LONG = new BigInteger(String.valueOf(Long.MIN_VALUE)); MAX_LONG = new BigInteger(String.valueOf(Long.MAX_VALUE)); - MAX_UNSIGNED_LONG = MAX_LONG.multiply(new BigInteger("2")).add(BigInteger.ONE); + MAX_UNSIGNED_LONG = MAX_LONG.multiply(TWO).add(BigInteger.ONE); } MAX_UNSIGNED_LONG_64 = (new BigInteger(String.valueOf(Long.MAX_VALUE))) - .multiply(new BigInteger("2")).add(BigInteger.ONE); + .multiply(TWO).add(BigInteger.ONE); } private IntJVMOption() { @@ -94,21 +104,34 @@ this.type = type; switch (type) { - case "uint64_t": - uint64 = true; + case "uint64_t": + unsigned = true; + uint64 = true; + max = MAX_UNSIGNED_LONG_64; + break; case "uintx": - case "size_t": + case "size_t": + unsigned = true; + max = MAX_UNSIGNED_LONG; + break; + case "uint": unsigned = true; + is32Bit = true; + max = MAX_4_BYTE_UNSIGNED_INT; + break; + case "int": + min = MIN_4_BYTE_INT; + max = MAX_4_BYTE_INT; + is32Bit = true; + break; + default: + min = MIN_LONG; + max = MAX_LONG; break; } if (unsigned) { min = BigInteger.ZERO; - max = MAX_UNSIGNED_LONG; - } - - if (uint64) { - max = MAX_UNSIGNED_LONG_64; } } @@ -229,18 +252,25 @@ protected List getInvalidValues() { List invalidValues = new ArrayList<>(); - if (min.compareTo(MIN_LONG) != 0) { - invalidValues.add(min.subtract(BigInteger.ONE).toString()); - } - - if (!unsigned && (max.compareTo(MAX_LONG) != 0)) { - invalidValues.add(max.add(BigInteger.ONE).toString()); - } - - if (unsigned - && ((!uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) - || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0)))) { - invalidValues.add(max.add(BigInteger.ONE).toString()); + if (withRange) { + /* Return invalid values only for options which have defined range in VM */ + if ((is32Bit && min.compareTo(MIN_4_BYTE_INT) != 0) + || (!is32Bit && min.compareTo(MIN_LONG) != 0)) { + invalidValues.add(min.subtract(BigInteger.ONE).toString()); + } + + if (!unsigned + && ((is32Bit && (max.compareTo(MAX_4_BYTE_INT) != 0)) + || (!is32Bit && (max.compareTo(MAX_LONG) != 0)))) { + invalidValues.add(max.add(BigInteger.ONE).toString()); + } + + if (unsigned + && ((is32Bit && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT) != 0)) + || (!is32Bit && !uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) + || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0)))) { + invalidValues.add(max.add(BigInteger.ONE).toString()); + } } return invalidValues; --- old/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java 2015-06-16 18:41:19.961576526 +0300 +++ new/test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java 2015-06-16 18:41:19.833576525 +0300 @@ -77,8 +77,10 @@ JVMOption parameter; switch (type) { + case "int": case "intx": case "size_t": + case "uint": case "uintx": case "uint64_t": parameter = new IntJVMOption(name, type); @@ -87,8 +89,9 @@ parameter = new DoubleJVMOption(name); break; default: - throw new Error("Expected only \"intx\", \"size_t\", \"uintx\", \"uint64_t\"," - + " or \"double\" option types! Got " + type + " type!"); + throw new Error("Expected only \"int\", \"intx\", \"size_t\", " + + "\"uint\", \"uintx\", \"uint64_t\", or \"double\" " + + "option types! Got " + type + " type!"); } return parameter; @@ -331,7 +334,7 @@ * @throws Exception if java process can not be started */ private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception { - int returnCode; + int exitCode; boolean result = true; String value = optionValue.substring(optionValue.lastIndexOf("=") + 1); String fullOptionString = prependString.toString() + optionValue; @@ -344,19 +347,19 @@ out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(true, runJava.toArray(new String[0])).start()); - returnCode = out.getExitValue(); + exitCode = out.getExitValue(); if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) { /* Always consider "fatal error" in output as fail */ - failedMessage(name, fullOptionString, valid, "JVM output reports a fatal error. JVM exited with code " + returnCode + "!"); + failedMessage(name, fullOptionString, valid, "JVM output reports a fatal error. JVM exited with code " + exitCode + "!"); printOutputContent(out); result = false; } else if (valid == true) { - if ((returnCode != 0) && (returnCode != 1)) { - failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + returnCode); + if ((exitCode != 0) && (exitCode != 1)) { + failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + exitCode); printOutputContent(out); result = false; - } else if ((returnCode == 1) && (out.getOutput().isEmpty() == true)) { + } else if ((exitCode == 1) && (out.getOutput().isEmpty() == true)) { failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == 1)" + ", but with empty stdout and stderr. Description of error is needed!"); result = false; @@ -367,12 +370,12 @@ } } else { // valid == false - if (returnCode == 0) { + if (exitCode == 0) { failedMessage(name, fullOptionString, valid, "JVM successfully exit"); result = false; - } else if (returnCode != 1) { + } else if (exitCode != 1) { failedMessage(name, fullOptionString, valid, "JVM exited with code " - + returnCode + " which not equal to 1"); + + exitCode + " which not equal to 1"); result = false; } else if (!out.getOutput().contains(getErrorMessageCommandLine(value))) { failedMessage(name, fullOptionString, valid, "JVM output does not contain "