[foreign-memaccess+abi] RFR: 8312186: TestStringEncodingFails for UTF-32

Jorn Vernee jvernee at openjdk.org
Mon Jul 17 20:33:25 UTC 2023


On Mon, 17 Jul 2023 19:30:12 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> The test is failing because there are now several UTF 32-based char sets in StandardCharsets, and the  FFM API can not handle these yet.
> 
> This patch adds support for the UTF 32 based char sets to `MemorySegment::getString(long, Charset)`, `MemorySegment::setString(long, String, Charset)`, and `SegmentAllocator::allocateFrom(String, Charset)`.

src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 58:

> 56:         long len = strlen_byte(segment, offset);
> 57:         byte[] bytes = new byte[(int)len];
> 58:         MemorySegment.copy(segment, ValueLayout.JAVA_BYTE, offset, bytes, 0, (int)len);

Note that I dropped the `ValueLayout.` prefix here and below to make the references to `JAVA_BYTE` consistent throughout the file.

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/847#discussion_r1265867821


More information about the panama-dev mailing list