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.

After some offline discussions Jorn and I have decided to leave things as they 
are and document the behavior. After all, there's no unsafety - and in some 
cases (e.g. concatenating multiple strings into a "flat" array whose elements 
are separated by terminators) it might even be desirable. The performance 
impact of checking all bytes and throwing is just too much: from 1.5 slower 
(with 100 chars) when using a standard allocator, up to 2.5x slower when using 
an optimized allocator. As a fallback, users could always resort to manual bulk 
copy, but the trade off would not be super obvious.

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

PR: https://git.openjdk.org/jdk19/pull/107

Reply via email to