< prev index next >
src/java.base/share/classes/java/time/temporal/ValueRange.java
Print this page
rev 58118 : 8239520: ValueRange.of(long, long, long) does not throw IAE on invalid inputs
Reviewed-by: rriggs
*** 1,7 ****
/*
! * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 143,152 ****
--- 143,155 ----
* @throws IllegalArgumentException if
* the minimum is greater than the smallest maximum,
* or the smallest maximum is greater than the largest maximum
*/
public static ValueRange of(long min, long maxSmallest, long maxLargest) {
+ if (min > maxSmallest) {
+ throw new IllegalArgumentException("Minimum value must be less than smallest maximum value");
+ }
return of(min, min, maxSmallest, maxLargest);
}
/**
* Obtains a fully variable value range.
*** 158,179 ****
* @param maxSmallest the smallest maximum value
* @param maxLargest the largest maximum value
* @return the ValueRange for smallest min, largest min, smallest max, largest max, not null
* @throws IllegalArgumentException if
* the smallest minimum is greater than the smallest maximum,
! * or the smallest maximum is greater than the largest maximum
! * or the largest minimum is greater than the largest maximum
*/
public static ValueRange of(long minSmallest, long minLargest, long maxSmallest, long maxLargest) {
if (minSmallest > minLargest) {
throw new IllegalArgumentException("Smallest minimum value must be less than largest minimum value");
}
if (maxSmallest > maxLargest) {
throw new IllegalArgumentException("Smallest maximum value must be less than largest maximum value");
}
if (minLargest > maxLargest) {
! throw new IllegalArgumentException("Minimum value must be less than maximum value");
}
return new ValueRange(minSmallest, minLargest, maxSmallest, maxLargest);
}
/**
--- 161,186 ----
* @param maxSmallest the smallest maximum value
* @param maxLargest the largest maximum value
* @return the ValueRange for smallest min, largest min, smallest max, largest max, not null
* @throws IllegalArgumentException if
* the smallest minimum is greater than the smallest maximum,
! * or the smallest maximum is greater than the largest maximum,
! * or the largest minimum is greater than the largest maximum,
! * or the smallest minimum is greater than the largest minimum
*/
public static ValueRange of(long minSmallest, long minLargest, long maxSmallest, long maxLargest) {
if (minSmallest > minLargest) {
throw new IllegalArgumentException("Smallest minimum value must be less than largest minimum value");
}
if (maxSmallest > maxLargest) {
throw new IllegalArgumentException("Smallest maximum value must be less than largest maximum value");
}
if (minLargest > maxLargest) {
! throw new IllegalArgumentException("Largest minimum value must be less than largest maximum value");
! }
! if (minSmallest > maxSmallest) {
! throw new IllegalArgumentException("Smallest minimum value must be less than smallest maximum value");
}
return new ValueRange(minSmallest, minLargest, maxSmallest, maxLargest);
}
/**
< prev index next >