When encoding a vary large string in String.getBytes(StandardCharset.UTF_8) computation of the buffer size may exceed the range of a positive 32-bit Integer. If the estimated size for the result byte array is too large, pre-compute the exact buffer size. If that exceeds the range, then throw OutOfMemoryError.
------------- Commit messages: - 8329623: NegativeArraySizeException encoding large String to UTF-8 Changes: https://git.openjdk.org/jdk/pull/18663/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18663&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8329623 Stats: 78 lines in 2 files changed: 76 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/18663.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/18663/head:pull/18663 PR: https://git.openjdk.org/jdk/pull/18663