< prev index next >

test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/IntJVMOption.java

Print this page

        

*** 33,49 **** --- 33,54 ---- private static final BigInteger MIN_LONG; private static final BigInteger MAX_LONG; 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 */ private BigInteger max;
*** 56,82 **** * Is this value signed or unsigned */ private boolean unsigned; /** * Is this value 64 bit unsigned */ private boolean uint64 = false; static { 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); } 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_64 = (new BigInteger(String.valueOf(Long.MAX_VALUE))) ! .multiply(new BigInteger("2")).add(BigInteger.ONE); } private IntJVMOption() { type = ""; } --- 61,92 ---- * Is this value signed or unsigned */ private boolean unsigned; /** + * Is this 32 bit type + */ + private boolean is32Bit = false; + + /** * Is this value 64 bit unsigned */ private boolean uint64 = false; static { 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(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(TWO).add(BigInteger.ONE); } MAX_UNSIGNED_LONG_64 = (new BigInteger(String.valueOf(Long.MAX_VALUE))) ! .multiply(TWO).add(BigInteger.ONE); } private IntJVMOption() { type = ""; }
*** 93,116 **** this.name = name; this.type = type; switch (type) { case "uint64_t": uint64 = true; case "uintx": case "size_t": unsigned = true; break; } if (unsigned) { min = BigInteger.ZERO; - max = MAX_UNSIGNED_LONG; - } - - if (uint64) { - max = MAX_UNSIGNED_LONG_64; } } /** * Initialize integer option with passed name, min and max values. Min and --- 103,139 ---- this.name = name; this.type = type; switch (type) { case "uint64_t": + unsigned = true; uint64 = true; + max = MAX_UNSIGNED_LONG_64; + break; case "uintx": 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; } } /** * Initialize integer option with passed name, min and max values. Min and
*** 227,249 **** */ @Override protected List<String> getInvalidValues() { List<String> 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()); } return invalidValues; } /** --- 250,279 ---- */ @Override protected List<String> getInvalidValues() { List<String> invalidValues = new ArrayList<>(); ! 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; } /**
< prev index next >