On Mon, 4 Jul 2022 13:01:34 GMT, Jorn Vernee <jver...@openjdk.org> wrote:
> This PR updates the spec and implementation to throw an > `IllegalArgumentException` when an attempt is made to convert a Java string > containing null characters to a C string. > > Testing: local run of the `jdk_foreign` test suite. It's tempting to allow null/0 characters to pass through, truncating the string, given the rarity of such characters, but it could hide a nasty bug. If performance becomes a really important issue we can make intrinsic and vectorize. I think it is better to refer to the characters in the String, rather than refer to bytes of the UTF-8 encoding of that String e.g. throws if the string contains a null character (same for the exception message). We can explain in an API note why. ------------- PR: https://git.openjdk.org/jdk19/pull/107