8263552: Use String.valueOf() for char-to-String conversions

Reviewed-by: redestad, vtewari, azvegint, chegar
This commit is contained in:
Sergey Tsypanov 2021-03-15 11:18:59 +00:00 committed by Claes Redestad
parent fac39fe97a
commit c0176c42dc
6 changed files with 6 additions and 6 deletions

View file

@ -830,7 +830,7 @@ public class ObjectStreamClass implements Serializable {
char tcode = (char) in.readByte(); char tcode = (char) in.readByte();
String fname = in.readUTF(); String fname = in.readUTF();
String signature = ((tcode == 'L') || (tcode == '[')) ? String signature = ((tcode == 'L') || (tcode == '[')) ?
in.readTypeString() : new String(new char[] { tcode }); in.readTypeString() : String.valueOf(tcode);
try { try {
fields[i] = new ObjectStreamField(fname, signature, false); fields[i] = new ObjectStreamField(fname, signature, false);
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -452,7 +452,7 @@ final class CryptoPolicyParser {
break; break;
default: default:
throw new ParsingException(st.lineno(), expect, throw new ParsingException(st.lineno(), expect,
new String(new char[] {(char)lookahead})); String.valueOf((char)lookahead));
} }
return value; return value;
} }

View file

@ -49,7 +49,7 @@ class SignatureIterator {
char c = sig.charAt(idx); char c = sig.charAt(idx);
if (c != '[' && c != 'L') { if (c != '[' && c != 'L') {
++idx; ++idx;
return new String(new char[] { c }); return String.valueOf(c);
} }
// Walk forward to end of entry // Walk forward to end of entry
int endIdx = idx; int endIdx = idx;

View file

@ -57,7 +57,7 @@ public enum Wrapper {
this.wrapperType = wtype; this.wrapperType = wtype;
this.primitiveType = ptype; this.primitiveType = ptype;
this.basicTypeChar = tchar; this.basicTypeChar = tchar;
this.basicTypeString = new String(new char[] {this.basicTypeChar}); this.basicTypeString = String.valueOf(this.basicTypeChar);
this.emptyArray = emptyArray; this.emptyArray = emptyArray;
this.format = format; this.format = format;
this.wrapperSimpleName = wtypeName; this.wrapperSimpleName = wtypeName;

View file

@ -812,7 +812,7 @@ public class PolicyParser {
break; break;
default: default:
throw new ParsingException(st.lineno(), expect, throw new ParsingException(st.lineno(), expect,
new String(new char[] {(char)lookahead})); String.valueOf((char)lookahead));
} }
return value; return value;
} }

View file

@ -465,7 +465,7 @@ public class NumberFormatter extends InternationalFormatter {
} }
else { else {
string = getReplaceString(offset, replaceLength, string = getReplaceString(offset, replaceLength,
new String(new char[] { aChar })); String.valueOf(aChar));
} }
return stringToValue(string); return stringToValue(string);
} }