8247681: Improve bootstrapping of unary concatenations

Reviewed-by: jlaskey, psandoz
This commit is contained in:
Claes Redestad 2020-06-17 19:36:26 +02:00
parent 1d87958ead
commit 34c79640e7
6 changed files with 149 additions and 19 deletions

View file

@ -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