JDK-8206932 : Add utility methods to check machine word indexes and ranges
  • Type: Enhancement
  • Component: core-libs
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2018-07-09
  • Updated: 2018-07-09
Related Reports
Relates :  
Relates :  
Relates :  
Description
JDK-8135248 added utility methods like Objects.checkIndex
to supply efficient checking of indexes for arrays and array-like
aggregates.  These methods operate on 32-bit indexes only.
They should be duplicated to also operate on 64-bit indexes.

One customer for this API is the bounds checking of Panama
pointers.  As with C, Panama pointer manipulation is important
to performance; unlike C, Panama pointers range-check their
pointers, so optimizing their range checks is a goal.

It would be sufficient for Panama to place these methods only
in jdk.internal.util.Preconditions, where the binder can get to them.

Both signed and unsigned versions of these checkers are plausible.
Panama needs only the signed 64-bit versions, at present.