mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8313809: String template fails with java.lang.StringIndexOutOfBoundsException if last fragment is UTF16
Reviewed-by: redestad
This commit is contained in:
parent
509f80bb04
commit
6864441163
2 changed files with 47 additions and 4 deletions
|
@ -1107,10 +1107,9 @@ public final class StringConcatFactory {
|
|||
MethodHandle mh = MethodHandles.dropArguments(newString(), 2, ttypes);
|
||||
|
||||
long initialLengthCoder = INITIAL_CODER;
|
||||
String lastFragment = "";
|
||||
pos = 0;
|
||||
for (String fragment : fragments) {
|
||||
lastFragment = fragment;
|
||||
initialLengthCoder = JLA.stringConcatMix(initialLengthCoder, fragment);
|
||||
|
||||
if (ttypes.length <= pos) {
|
||||
break;
|
||||
|
@ -1118,14 +1117,15 @@ public final class StringConcatFactory {
|
|||
|
||||
Class<?> ttype = ttypes[pos];
|
||||
// (long,byte[],ttype) -> long
|
||||
MethodHandle prepender = prepender(lastFragment.isEmpty() ? null : fragment, ttype);
|
||||
initialLengthCoder = JLA.stringConcatMix(initialLengthCoder, fragment);
|
||||
MethodHandle prepender = prepender(fragment.isEmpty() ? null : fragment, ttype);
|
||||
// (byte[],long,ttypes...) -> String (unchanged)
|
||||
mh = MethodHandles.filterArgumentsWithCombiner(mh, 1, prepender,1, 0, 2 + pos);
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
String lastFragment = fragments.getLast();
|
||||
initialLengthCoder -= lastFragment.length();
|
||||
MethodHandle newArrayCombinator = lastFragment.isEmpty() ? newArray() :
|
||||
newArrayWithSuffix(lastFragment);
|
||||
// (long,ttypes...) -> String
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue