<Swing Dev> RFR: 8263552: Use String.valueOf() for char-to-String conversion in ObjectStreamClass

Claes Redestad redestad at openjdk.java.net
Sat Mar 13 15:22:08 UTC 2021


On Sat, 20 Feb 2021 12:17:32 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

> This is a very simple and trivial improvement about getting rid of pointless char wrapping into array

LGTM

src/java.base/share/classes/java/io/ObjectStreamClass.java line 833:

> 831:             String fname = in.readUTF();
> 832:             String signature = ((tcode == 'L') || (tcode == '[')) ?
> 833:                 in.readTypeString() : String.valueOf(tcode);

Since the result of String.valueOf here will be equal to one of the primitive signatures strings ("I", "J", ...) (otherwise ObjectStreamField will throw an exception) it might make sense to turn this into a switch expression and simplify the whole thing. I can't tell how performance sensitive this piece of code is, though.

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

Marked as reviewed by redestad (Reviewer).

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


More information about the swing-dev mailing list