183 /** 184 * Get string with maximum value of the option 185 * 186 * @return string with maximum value of the option 187 */ 188 @Override 189 String getMax() { 190 return max.toString(); 191 } 192 193 /** 194 * Return list of strings with valid option values which used for testing 195 * using jcmd, attach and etc. 196 * 197 * @return list of strings which contain valid values for option 198 */ 199 @Override 200 protected List<String> getValidValues() { 201 List<String> validValues = new ArrayList<>(); 202 203 validValues.add(min.toString()); 204 validValues.add(max.toString()); 205 206 if ((min.compareTo(MINUS_ONE) == -1) && (max.compareTo(MINUS_ONE) == 1)) { 207 /* 208 * Add -1 as valid value if min is less than -1 and max is greater than -1 209 */ 210 validValues.add("-1"); 211 } 212 213 if ((min.compareTo(BigInteger.ZERO) == -1) && (max.compareTo(BigInteger.ZERO) == 1)) { 214 /* 215 * Add 0 as valid value if min is less than 0 and max is greater than 0 216 */ 217 validValues.add("0"); 218 } 219 if ((min.compareTo(BigInteger.ONE) == -1) && (max.compareTo(BigInteger.ONE) == 1)) { 220 /* 221 * Add 1 as valid value if min is less than 1 and max is greater than 1 222 */ 223 validValues.add("1"); 224 } 225 226 if ((min.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == -1) && (max.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == 1)) { 227 /* 228 * Check for overflow when flag is assigned to the 229 * 4 byte int variable 230 */ 231 validValues.add(MAX_4_BYTE_INT_PLUS_ONE.toString()); 232 } 233 234 if ((min.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == -1) && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == 1)) { 235 /* 236 * Check for overflow when flag is assigned to the 237 * 4 byte unsigned int variable 238 */ 239 validValues.add(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE.toString()); 240 } 241 242 return validValues; 243 } 244 245 /** 246 * Return list of strings with invalid option values which used for testing 247 * using jcmd, attach and etc. 248 * 249 * @return list of strings which contain invalid values for option 250 */ 251 @Override 252 protected List<String> getInvalidValues() { 253 List<String> invalidValues = new ArrayList<>(); 254 255 if (withRange) { 256 /* Return invalid values only for options which have defined range in VM */ 257 if ((is32Bit && min.compareTo(MIN_4_BYTE_INT) != 0) 258 || (!is32Bit && min.compareTo(MIN_LONG) != 0)) { 259 invalidValues.add(min.subtract(BigInteger.ONE).toString()); 260 } 261 262 if (!unsigned 263 && ((is32Bit && (max.compareTo(MAX_4_BYTE_INT) != 0)) 264 || (!is32Bit && (max.compareTo(MAX_LONG) != 0)))) { 265 invalidValues.add(max.add(BigInteger.ONE).toString()); 266 } 267 268 if (unsigned 269 && ((is32Bit && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT) != 0)) 270 || (!is32Bit && !uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) 271 || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0)))) { 272 invalidValues.add(max.add(BigInteger.ONE).toString()); 273 } 274 } 275 276 return invalidValues; 277 } 278 279 /** 280 * Return expected error message for option with value "value" when it used 281 * on command line with passed value 282 * 283 * @param value Option value 284 * @return expected error message 285 */ 286 @Override 287 protected String getErrorMessageCommandLine(String value) { 288 String errorMsg; 289 290 if (withRange) { 291 /* Option have defined range in VM */ 292 if (unsigned && ((new BigInteger(value)).compareTo(BigInteger.ZERO) < 0)) { | 183 /** 184 * Get string with maximum value of the option 185 * 186 * @return string with maximum value of the option 187 */ 188 @Override 189 String getMax() { 190 return max.toString(); 191 } 192 193 /** 194 * Return list of strings with valid option values which used for testing 195 * using jcmd, attach and etc. 196 * 197 * @return list of strings which contain valid values for option 198 */ 199 @Override 200 protected List<String> getValidValues() { 201 List<String> validValues = new ArrayList<>(); 202 203 if (testMinRange) { 204 validValues.add(min.toString()); 205 } 206 if (testMaxRange) { 207 validValues.add(max.toString()); 208 } 209 210 if (testMinRange) { 211 if ((min.compareTo(MINUS_ONE) == -1) && (max.compareTo(MINUS_ONE) == 1)) { 212 /* 213 * Add -1 as valid value if min is less than -1 and max is greater than -1 214 */ 215 validValues.add("-1"); 216 } 217 218 if ((min.compareTo(BigInteger.ZERO) == -1) && (max.compareTo(BigInteger.ZERO) == 1)) { 219 /* 220 * Add 0 as valid value if min is less than 0 and max is greater than 0 221 */ 222 validValues.add("0"); 223 } 224 if ((min.compareTo(BigInteger.ONE) == -1) && (max.compareTo(BigInteger.ONE) == 1)) { 225 /* 226 * Add 1 as valid value if min is less than 1 and max is greater than 1 227 */ 228 validValues.add("1"); 229 } 230 } 231 232 if (testMaxRange) { 233 if ((min.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == -1) && (max.compareTo(MAX_4_BYTE_INT_PLUS_ONE) == 1)) { 234 /* 235 * Check for overflow when flag is assigned to the 236 * 4 byte int variable 237 */ 238 validValues.add(MAX_4_BYTE_INT_PLUS_ONE.toString()); 239 } 240 241 if ((min.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == -1) && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE) == 1)) { 242 /* 243 * Check for overflow when flag is assigned to the 244 * 4 byte unsigned int variable 245 */ 246 validValues.add(MAX_4_BYTE_UNSIGNED_INT_PLUS_ONE.toString()); 247 } 248 } 249 250 return validValues; 251 } 252 253 /** 254 * Return list of strings with invalid option values which used for testing 255 * using jcmd, attach and etc. 256 * 257 * @return list of strings which contain invalid values for option 258 */ 259 @Override 260 protected List<String> getInvalidValues() { 261 List<String> invalidValues = new ArrayList<>(); 262 263 /* Return invalid values only for options which have defined range in VM */ 264 if (withRange) { 265 if (unsigned) { 266 /* Only add non-negative out-of-range values for unsigned options */ 267 if (min.compareTo(BigInteger.ZERO) == 1) { 268 invalidValues.add(min.subtract(BigInteger.ONE).toString()); 269 } 270 271 if ((is32Bit && (max.compareTo(MAX_4_BYTE_UNSIGNED_INT) != 0)) 272 || (!is32Bit && !uint64 && (max.compareTo(MAX_UNSIGNED_LONG) != 0)) 273 || (uint64 && (max.compareTo(MAX_UNSIGNED_LONG_64) != 0))) { 274 invalidValues.add(max.add(BigInteger.ONE).toString()); 275 } 276 } else { 277 if ((is32Bit && min.compareTo(MIN_4_BYTE_INT) != 0) 278 || (!is32Bit && min.compareTo(MIN_LONG) != 0)) { 279 invalidValues.add(min.subtract(BigInteger.ONE).toString()); 280 } 281 if ((is32Bit && (max.compareTo(MAX_4_BYTE_INT) != 0)) 282 || (!is32Bit && (max.compareTo(MAX_LONG) != 0))) { 283 invalidValues.add(max.add(BigInteger.ONE).toString()); 284 } 285 } 286 } 287 288 return invalidValues; 289 } 290 291 /** 292 * Return expected error message for option with value "value" when it used 293 * on command line with passed value 294 * 295 * @param value Option value 296 * @return expected error message 297 */ 298 @Override 299 protected String getErrorMessageCommandLine(String value) { 300 String errorMsg; 301 302 if (withRange) { 303 /* Option have defined range in VM */ 304 if (unsigned && ((new BigInteger(value)).compareTo(BigInteger.ZERO) < 0)) { |