RFR 8135248: Add utility methods to check indexes and ranges

Paul Sandoz paul.sandoz at oracle.com
Mon Sep 21 14:28:17 UTC 2015

On 21 Sep 2015, at 15:52, Stephen Colebourne <scolebourne at joda.org> wrote:

> While I think I understand the need for the lambda/exception interface
> (backwards compatibility) it is definitely weird as a method
> signature.

Backwards compat has definitely influenced things, but the approach was also considered useful for new cases where customized exceptions/messages are required.

> It would seem very worthwhile to add overloaded versions of each of
> these methods that do not have the OutOfBoundsToException in the
> argument list. Instead, these overloads would throw a "standard"
> exception.

That seems reasonable e.g.:

public static
int checkIndex(int index, int length) IndexOutOfBoundsException {
    return checkIndex(index, length, null);

> Such methods would then be much more amenable to just being
> dropped into existing application code, where the precise exception
> that is thrown is less of a concern.

Though is passing “null” such a big deal?


More information about the core-libs-dev mailing list