Details
-
Bug
-
Resolution: Fixed
-
P1
-
22
-
b27
-
b10
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8325605 | 22.0.1 | Roger Riggs | P1 | Closed | Fixed | b05 |
Description
Repro:
```
import static java.nio.charset.StandardCharsets.UTF_16;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
public class Y {
public static void main(String[] args) throws IOException {
String original = "🤸";
Path tmp = Files.createTempFile("tmp", ".txt");
Files.writeString(tmp, original, UTF_16);
String actual = Files.readString(tmp, UTF_16);
System.err.printf("expected (%s), was (%s)\n", original, actual);
System.err.printf("expected UTF_16 bytes: %s\n", Arrays.toString(original.getBytes(UTF_16)));
System.err.printf("actual UTF_16 bytes: %s\n", Arrays.toString(actual.getBytes(UTF_16)));
}
}
```
$ java -fullversion
openjdk full version "21.0.2+13-58"
$ java Y
expected (🤸), was (🤸)
expected UTF_16 bytes: [-2, -1, -40, 62, -35, 56]
actual UTF_16 bytes: [-2, -1, -40, 62, -35, 56]
$ java -fullversion
openjdk full version "22+35-2369"
$ java Y
expected (🤸), was (>Ø8Ý)
expected UTF_16 bytes: [-2, -1, -40, 62, -35, 56]
actual UTF_16 bytes: [-2, -1, 0, 62, 0, -40, 0, 56, 0, -35]
Attachments
Issue Links
- backported by
-
JDK-8325605 Regression in round-tripping UTF-16 strings after JDK-8311906
- Closed
- duplicates
-
JDK-8328714 Shift_JIS encoded content gets garbled with Java 22
- Closed
- relates to
-
JDK-8311906 Improve robustness of String constructors with mutable array inputs
- Closed
- links to
-
Commit openjdk/jdk22u/32b3998c
-
Commit openjdk/jdk/13d9e8ff
-
Review openjdk/jdk22/110
-
Review openjdk/jdk22u/52
-
Review openjdk/jdk22u/55
-
Review openjdk/jdk/17817