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

Chen Liang liach at openjdk.org
Sun Mar 9 18:13:52 UTC 2025


On Sun, 9 Mar 2025 14:38:45 GMT, Alan Bateman <alanb 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.

These seem to be strings from localization, so I think it's unlikely to have 4-byte unicode characters appearing.

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

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


More information about the core-libs-dev mailing list