As suggested on mailing list, when encoding latin1 bytes to utf-8, we can count the leading positive bytes and in the case where there is a negative, we can copy all the positive values to the target byte[] prior to processing the remaining data 1 byte at a time.
https://mail.openjdk.org/pipermail/core-libs-dev/2025-July/149417.html ------------- Commit messages: - whitespace - use counted positive values when converting latin1 to utf-8 Changes: https://git.openjdk.org/jdk/pull/26597/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26597&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8364320 Stats: 9 lines in 1 file changed: 6 ins; 1 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/26597.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/26597/head:pull/26597 PR: https://git.openjdk.org/jdk/pull/26597