[foreign-memaccess+abi] RFR: 8268230: Foreign Linker API & Windows user32/kernel32: String conversion seems broken

Jorn Vernee jvernee at openjdk.java.net
Thu Jun 10 12:12:46 UTC 2021


The problem is that we only add a single 0 byte as a null terminator, regardless of the charset used. For wider char sets, more 0 bytes need to be added. For instance, for UTF_16LE two 0 bytes need to be added.

This patch fixes the issue by adding the null terminator to the Java string, and only then encoding it as a `byte[]`.

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

Commit messages:
 - Fix toCString for wider character sets

Changes: https://git.openjdk.java.net/panama-foreign/pull/554/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=554&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8268230
  Stats: 85 lines in 2 files changed: 75 ins; 6 del; 4 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/554.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/554/head:pull/554

PR: https://git.openjdk.java.net/panama-foreign/pull/554


More information about the panama-dev mailing list