JDK-8146668 : Replace custom check/range functionality with check index/range methods in java.util.Objects
  • Type: Bug
  • Component: core-libs
  • Priority: P4
  • Status: In Progress
  • Resolution: Unresolved
  • Submitted: 2016-01-08
  • Updated: 2020-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
JDK-8135248 will provide public methods in java.util.Arrays for checking indexes and ranges. Existing code with custom check/range functionality can be updated to use these methods. 

The following classes have been currently identified as candidates to be modified: java.lang.String, java.lang.AbstractStringBuilder, java.util.Arrays, java.util.Spliterators, and java.nio.Buffer.
Comments
Tested with ArrayList/RangeCheckMicroBenchmark.java, no performance regression. Result: without 8146668: =========== get 26 1 set 40.6 1.5707 get/set 85.7 3.3002 add/remove at end 337.5 12.9197 subList get 25 0.9747 subList set 59.9 2.3 subList get/set 92.2 3.5414 subList add/remove at end 429.8 16.45 with 8146668: =========== get 26 1 set 39.1 1.5188 get/set 86.8 3.3363 add/remove at end 335.5 12.8549 subList get 24.8 0.9715 subList set 59.2 2.2728 subList get/set 92.2 3.5473 subList add/remove at end 427.7 16.3789 Also tried java/nio/Buffer/SwapMicroBenchmark.java, no performance regression. without 8146668 ============= swap char LITTLE_ENDIAN 11 1 swap short LITTLE_ENDIAN 10.2 0.9895 swap int LITTLE_ENDIAN 5 0.4961 swap long LITTLE_ENDIAN 3 0.3345 with 8146668 ============ swap char LITTLE_ENDIAN 10.1 1 swap short LITTLE_ENDIAN 10.1 0.9995 swap int LITTLE_ENDIAN 5 0.5005 swap long LITTLE_ENDIAN 3 0.3327
16-01-2017

Thank you Martin! Noticed jdk/test/java/util/ArrayList/RangeCheckMicroBenchmark.java Let me try it.
12-01-2017

Are you aware of RangeCheckMicroBenchmark?
12-01-2017

Candidates to be modified: java.lang.AbstractStringBuilder java.lang.String and StringLatin1 StringUTF16 java.nio.Buffer and related templates java.util.Arrays java.util.Spliterators Type of exception thrown should be preserved (but not necessarily the exception message). RFR: http://cr.openjdk.java.net/~amlu/8146668/webrev.01
12-01-2017

It would be awesome if the exceptions were consistent reliable and informative, but I worry that for core classes there is too much compatibility legacy for exception message details and whether code threw IOOBE or AIOOBE. I also worry about possible performance impact. At least run microbenchmarks for ArrayList.
12-01-2017