--- 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;