Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8263552: Use String.valueOf() for char-to-String conversions
Reviewed-by: redestad, vtewari, azvegint, chegar
  • Loading branch information
stsypanov authored and cl4es committed Mar 15, 2021
1 parent fac39fe commit c0176c4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/io/ObjectStreamClass.java
Expand Up @@ -830,7 +830,7 @@ void readNonProxy(ObjectInputStream in)
char tcode = (char) in.readByte();
String fname = in.readUTF();
String signature = ((tcode == 'L') || (tcode == '[')) ?
in.readTypeString() : new String(new char[] { tcode });
in.readTypeString() : String.valueOf(tcode);
try {
fields[i] = new ObjectStreamField(fname, signature, false);
} catch (RuntimeException e) {
Expand Down
Expand Up @@ -452,7 +452,7 @@ else if (expect.equalsIgnoreCase("permission type")) {
break;
default:
throw new ParsingException(st.lineno(), expect,
new String(new char[] {(char)lookahead}));
String.valueOf((char)lookahead));
}
return value;
}
Expand Down
Expand Up @@ -49,7 +49,7 @@ public String next() {
char c = sig.charAt(idx);
if (c != '[' && c != 'L') {
++idx;
return new String(new char[] { c });
return String.valueOf(c);
}
// Walk forward to end of entry
int endIdx = idx;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/sun/invoke/util/Wrapper.java
Expand Up @@ -57,7 +57,7 @@ private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeNa
this.wrapperType = wtype;
this.primitiveType = ptype;
this.basicTypeChar = tchar;
this.basicTypeString = new String(new char[] {this.basicTypeChar});
this.basicTypeString = String.valueOf(this.basicTypeChar);
this.emptyArray = emptyArray;
this.format = format;
this.wrapperSimpleName = wtypeName;
Expand Down
Expand Up @@ -812,7 +812,7 @@ private String match(String expect)
break;
default:
throw new ParsingException(st.lineno(), expect,
new String(new char[] {(char)lookahead}));
String.valueOf((char)lookahead));
}
return value;
}
Expand Down
Expand Up @@ -465,7 +465,7 @@ private Object toggleExponentSign(int offset, char aChar) throws
}
else {
string = getReplaceString(offset, replaceLength,
new String(new char[] { aChar }));
String.valueOf(aChar));
}
return stringToValue(string);
}
Expand Down

1 comment on commit c0176c4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.