8325590: Regression in round-tripping UTF-16 strings after JDK-8311906

Reviewed-by: alanb, redestad
This commit is contained in:
Roger Riggs 2024-02-13 15:16:50 +00:00
parent 57b04e1b5d
commit 13d9e8ff38
2 changed files with 37 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -841,7 +841,7 @@ public final class String
}
if (COMPACT_STRINGS) {
byte[] val = StringUTF16.compress(ca, 0, caLen);
int coder = StringUTF16.coderFromArrayLen(val, len);
byte coder = StringUTF16.coderFromArrayLen(val, caLen);
return new String(val, coder);
}
return new String(StringUTF16.toBytes(ca, 0, caLen), UTF16);