RFR: 8364317: Explicitly document some assumptions of StringUTF16

Chen Liang liach at openjdk.org
Tue Jul 29 21:15:07 UTC 2025


In #24773, people were concerned that the layout of a UTF16 byte array and a char array may be incompatible. In fact, they are - they are asserted in a corner in `LibraryCallKit::inline_string_char_access` in `library_call.cpp`.

In addition, another frequent error I see is that contributors have confused the meaning of indices in StringUTF16 - the indices are always in char array indices. I think we should make these explicit to help future maintenance.

-------------

Commit messages:
 - Miscellaneous docs and checks for UTF16

Changes: https://git.openjdk.org/jdk/pull/26541/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26541&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8364317
  Stats: 7 lines in 1 file changed: 7 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/26541.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26541/head:pull/26541

PR: https://git.openjdk.org/jdk/pull/26541


More information about the core-libs-dev mailing list