On Tue, 7 Feb 2023 14:57:52 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update StringLatin1.trim for consistency > > src/java.base/share/classes/java/lang/String.java line 4546: > >> 4544: // To avoid surprises due to data races (which would either >> truncate or throw an exception) >> 4545: // we should check that length <= val.length up front >> 4546: checkOffset(length, val.length); > > I agree a check is needed here but I assume using checkOffset means that > SB::toString could fail with SIOOBE. I wonder if Math.min(length, val.length) > would be better here. Ok. That keeps behavior consistent for most cases and removes a path where we can fail with SIOOBE in the existing code (down `StringUTF16::compress`). ------------- PR: https://git.openjdk.org/jdk/pull/12453