RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated. ------------- Commit messages: - [PATCH] Cleanup usages of StringBuffer in java.base module - [PATCH] Cleanup usages of StringBuffer in java.base module Changes: https://git.openjdk.java.net/jdk/pull/5432/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5432&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8274879 Stats: 32 lines in 12 files changed: 0 ins; 0 del; 32 mod Patch: https://git.openjdk.java.net/jdk/pull/5432.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5432/head:pull/5432 PR: https://git.openjdk.java.net/jdk/pull/5432
On Thu, 9 Sep 2021 06:50:21 GMT, Andrey Turbanov <github.com+741251+turbanoff@openjdk.org> wrote:
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.
src/java.base/share/classes/java/lang/Character.java line 123:
121: * than U+FFFF are called <em>supplementary character</em>s. The Java 122: * platform uses the UTF-16 representation in {@code char} arrays and 123: * in the {@code String} and {@code StringBuilder} classes. In
Not sure simple replacement applies here, as `StringBuffer` still uses `UTF-16` representation. You may add `StringBuilder` as well here, but I think you might want to file a CSR to clarify. ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
On Thu, 7 Oct 2021 16:48:06 GMT, Naoto Sato <naoto@openjdk.org> wrote:
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.
src/java.base/share/classes/java/lang/Character.java line 123:
121: * than U+FFFF are called <em>supplementary character</em>s. The Java 122: * platform uses the UTF-16 representation in {@code char} arrays and 123: * in the {@code String} and {@code StringBuilder} classes. In
Not sure simple replacement applies here, as `StringBuffer` still uses `UTF-16` representation. You may add `StringBuilder` as well here, but I think you might want to file a CSR to clarify.
reverted changes in this spec. ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
On Mon, 11 Oct 2021 21:05:46 GMT, Andrey Turbanov <duke@openjdk.java.net> wrote:
src/java.base/share/classes/java/lang/Character.java line 123:
121: * than U+FFFF are called <em>supplementary character</em>s. The Java 122: * platform uses the UTF-16 representation in {@code char} arrays and 123: * in the {@code String} and {@code StringBuilder} classes. In
Not sure simple replacement applies here, as `StringBuffer` still uses `UTF-16` representation. You may add `StringBuilder` as well here, but I think you might want to file a CSR to clarify.
reverted changes in this spec.
Did you modify the PR? I am unable to locate the revert. ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
On Tue, 12 Oct 2021 20:33:20 GMT, Naoto Sato <naoto@openjdk.org> wrote:
reverted changes in this spec.
Did you modify the PR? I am unable to locate the revert.
Oops. Forgot to push ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.
Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes revert changes in spec to avoid CSR ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/5432/files - new: https://git.openjdk.java.net/jdk/pull/5432/files/14005d1d..c8d68c2a Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=5432&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=5432&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/5432.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5432/head:pull/5432 PR: https://git.openjdk.java.net/jdk/pull/5432
On Tue, 12 Oct 2021 20:39:13 GMT, Andrey Turbanov <duke@openjdk.java.net> wrote:
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.
Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
8274879: Replace uses of StringBuffer with StringBuilder within java.base classes revert changes in spec to avoid CSR
Marked as reviewed by naoto (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
On Thu, 9 Sep 2021 06:50:21 GMT, Andrey Turbanov <duke@openjdk.java.net> wrote:
StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better: 1. Plain String concatenation should be preferred 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029) I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.
This pull request has now been integrated. Changeset: 9a3e9542 Author: Andrey Turbanov <turbanoff@gmail.com> Committer: Naoto Sato <naoto@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/9a3e9542997860de79d07a4411b1007e9cd5... Stats: 31 lines in 11 files changed: 0 ins; 0 del; 31 mod 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes Reviewed-by: naoto ------------- PR: https://git.openjdk.java.net/jdk/pull/5432
participants (3)
-
Andrey Turbanov
-
Andrey Turbanov
-
Naoto Sato