RFR: 8349984: (jdeps) jdeps can use String.repeat instead of String.replaceAll

Alan Bateman alanb at openjdk.org
Sun Mar 9 14:41:07 UTC 2025


On Sat, 8 Mar 2025 00:28:15 GMT, Henry Jen <henryjen at openjdk.org> wrote:

> JDK-8349989: jlink can use String.replace instead of String.replaceAll

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java line 794:

> 792:                     log.format("%-40s %s%n",
> 793:                                "-".repeat(internalApiTitle.length()),
> 794:                                "_".repeat(replacementApiTitle.length()));

Using replaceAll to replace all characters with "-" is indeed a bit unusual. Are you sure String::length is what you want, I'm just wondering if you need the number of Unicode code points  here rather than length.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23954#discussion_r1986339411


More information about the core-libs-dev mailing list