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

Henry Jen henryjen at openjdk.org
Mon Mar 10 17:17:00 UTC 2025


On Sun, 9 Mar 2025 18:11:07 GMT, Chen Liang <liach at openjdk.org> wrote:

>> 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.

To have exactly same behavior, I think Alan is correct to use code point count here. Although unlikely as @liach pointed out.

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

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


More information about the core-libs-dev mailing list