mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8247681: Improve bootstrapping of unary concatenations
Reviewed-by: jlaskey, psandoz
This commit is contained in:
parent
1d87958ead
commit
34c79640e7
6 changed files with 149 additions and 19 deletions
|
@ -426,6 +426,22 @@ final class StringConcatHelper {
|
|||
return newString(buf, indexCoder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a String from a concatenation of single argument, which we
|
||||
* end up using for trivial concatenations like {@code "" + arg}.
|
||||
*
|
||||
* This will always create a new Object to comply with JLS 15.18.1:
|
||||
* "The String object is newly created unless the expression is a
|
||||
* compile-time constant expression".
|
||||
*
|
||||
* @param arg the only argument
|
||||
* @return String resulting string
|
||||
*/
|
||||
@ForceInline
|
||||
static String newStringOf(Object arg) {
|
||||
return new String(stringOf(arg));
|
||||
}
|
||||
|
||||
/**
|
||||
* We need some additional conversion for Objects in general, because
|
||||
* {@code String.valueOf(Object)} may return null. String conversion rules
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue