RFR: 8265518: C1: Intrinsic support for Preconditions.checkIndex [v6]
Paul Sandoz
psandoz at openjdk.java.net
Sat May 8 15:56:05 UTC 2021
On Sat, 8 May 2021 05:32:00 GMT, Yi Yang <yyang at openjdk.org> wrote:
> It seems that Object.checkIndex can not meet our needs because it implicitly passes null to Preconditions.checkIndex, but we want to customize exception messages, so we might add extra APIs in Objects while doing the replacement.
>
It might be possible to directly use `Preconditions.checkIndex` for such purposes, its package is non-exported but public for reuse within `java.base`. It's used in `VarHandle` `byte` array access code, see [here](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template#L117).
I would caution against adding a public API to support this. The work in `Preconditions` was the basis for a public API, but it proved complicated. I am glad we did not expose that, it would of made exposing the long accepting `Objects.checkIndex` methods more difficult.
Paul.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3615
More information about the hotspot-compiler-dev
mailing list