private static String badPositionIndex(int index, int size, String desc) {
        if (index < 0) {
            return String.format("%s (%s) must not be negative", desc, index);
        } else if (size < 0) {
            throw new IllegalArgumentException("negative size: " + size);
        } else { // index > size
            return String.format("%s (%s) must not be greater than size (%s)", desc, index, size);
        }
    }
Ensures that {@code start} and {@code end} specify a valid <i>positions</i> in an array, list
or string of size {@code size}, and are in order. A position index may range from zero to
{@code size}, inclusive.

@param start a user-supplied index identifying a starting position in an array, list or string
@param end a user-supplied index identifying a ending position in an array, list or string
@param size the size of that array, list or string
@throws IndexOutOfBoundsException if either index is negative or is greater than {@code size},
    or if {@code end} is less than {@code start}
@throws IllegalArgumentException if {@code size} is negative
common/src/main/java/org/conscrypt/Preconditions.java