RFR: 8264029: Replace uses of StringBuffer with StringBuilder in java.base

Andrey Turbanov github.com+741251+turbanoff at openjdk.java.net
Tue Mar 23 20:49:46 UTC 2021


On Tue, 23 Mar 2021 12:38:06 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> Found by IntelliJ IDEA inspection `Java | Java language level migration aids | Java 5 | 'StringBuffer' may be 'StringBuilder'`
>> As suggested in https://github.com/openjdk/jdk/pull/1507#issuecomment-757369003 I've created separate PR for module `java.base`
>> Similar cleanup in the past - https://bugs.openjdk.java.net/browse/JDK-8041679
>
> src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java line 1954:
> 
>> 1952:             for (int i = 0; i < 4; ++i) {
>> 1953:                 if (i > 0) {
>> 1954:                     sb.append("       ");
> 
> Consider using `String.repeat` here and on L1960 for clarity.

I'm not sure how String.repeat can be used here. Repeated String is not constant and different for each iteration.

> src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java line 1954:
> 
>> 1952:             for (int i = 0; i < 4; ++i) {
>> 1953:                 if (i > 0) {
>> 1954:                     sb.append("       ");
> 
> Consider using `String.repeat` here and on L1960 for clarity.

I don't think it can be used here.

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

PR: https://git.openjdk.java.net/jdk/pull/2922


More information about the nio-dev mailing list