RFR: 8356439: Rename JavaLangAccess::*NoRepl methods [v2]

Chen Liang liach at openjdk.org
Sun Aug 10 14:48:13 UTC 2025


On Fri, 8 Aug 2025 13:38:31 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> `NoRepl`-suffixed `String` methods denote methods that do not replace invalid characters, but throw `CharacterCodingException` on encounter. This behavior cannot easily be derived from the method footprints, has been a source of confusion for maintainers, and is not uniformly adopted, e.g., `newStringUTF8NoRepl()` and `getBytesUTF8NoRepl()` does *not* throw `CCE`. This PR removes `NoRepl` suffix from method names and consistently uses `throws CCE` in method footprints. (b4845109e18 passes `tier1,2`.)
>
> Volkan Yazici has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Group `String` methods by `doReplace` argument
>  - Merge remote-tracking branch 'upstream/master' into jlaNoRepl
>  - Replace `requireNonNull` with implicit null checks
>  - Merge remote-tracking branch 'upstream/master' into jlaNoRepl
>  - Improve docs of touched methods and add NPE checks
>  - Convert IAE-throwing methods into CCE-throwing ones
>  - Rename `JavaLangAccess::*NoRepl` methods

Review still in progress, feel free to ping me more more...

src/java.base/share/classes/java/lang/String.java line 949:

> 947:     static byte[] getBytesNoReplacement(String s, Charset cs) throws CharacterCodingException {
> 948:         Objects.requireNonNull(s, "s");
> 949:         Objects.requireNonNull(cs, "cs");

#26600 and subsequent PRs will add variable name reporting, so you can omit the string message to reduce bytecode size.

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

PR Review: https://git.openjdk.org/jdk/pull/26413#pullrequestreview-3101693404
PR Review Comment: https://git.openjdk.org/jdk/pull/26413#discussion_r2263645886


More information about the security-dev mailing list