On Wed, 25 Feb 2026 15:37:02 GMT, Patrick Strawderman <[email protected]> wrote:

> Avoid a byte array copy in encodeToString by using 
> JavaLangAccess#uncheckedNewStringWithLatin1Bytes

src/java.base/share/classes/java/util/Base64.java line 351:

> 349:          */
> 350:         public String encodeToString(byte[] src) {
> 351:             byte[] encoded = encode(src);

Consider adding a comment here to make it clear that `encoded` is guaranteed to 
be ASCII-only.

Otherwise, using `uncheckedNewStringWithLatin1Bytes` would not be safe. Better 
to make this contract explicit with a comment.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29920#discussion_r2858168126

Reply via email to