In #4738 we removed the `checkIndex(value, count)` call in `ASB.charAt` to avoid potentially getting two bounds checks in the UTF-16 case. Problem is this optimization cause a regression since `StringUTF16.charAt(..)` checks `index` against the length of the `value` array and not `count`.
A correct fix that still maintain the possible performance advantage reported by #4738 is to reinstate the `checkIndex(value, count)` and call `StringUTF16.getChar` instead of `charAt`. ------------- Commit messages: - 8271732: Regression in StringBuilder.charAt bounds checking Changes: https://git.openjdk.java.net/jdk/pull/5086/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5086&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8271732 Stats: 24 lines in 2 files changed: 22 ins; 0 del; 2 mod Patch: https://git.openjdk.java.net/jdk/pull/5086.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5086/head:pull/5086 PR: https://git.openjdk.java.net/jdk/pull/5086