From 08929964be2ef1a4c32e3cbb6cdbef2e89758175 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 19 Jan 2026 23:01:14 +0100 Subject: [PATCH] Add a note about malformed-input and unmappable-character sequences --- src/java.base/share/classes/java/lang/String.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index 0541e706e7d..ad1e2d3873b 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -2106,6 +2106,9 @@ public final class String /** * {@return the length in bytes of the given String encoded with the given {@link Charset}} * + *

The returned length accounts for the replacement of malformed-input and unmappable-character + * sequences with the charset's default replacement byte array. + * *

The result will be the same value as {@link #getBytes(Charset) getBytes(cs).length}. * * @apiNote This method provides equivalent or better performance than {@link #getBytes(Charset)