[foreign-memaccess+abi] RFR: 8308858: FFM API and strings [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jun 7 23:43:02 UTC 2023


On Wed, 7 Jun 2023 18:16:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> I also feel like we essentially kick the problem back to the user, since they now have to figure out the number of null terminator bytes.

On this I'm not 100% sure. I mean, there's a way in which what you say is correct, e.g. if you take it that the number of terminator bytes must be somewhat related to the charset selected by the user. But there's another way to look at this which says that the number of terminator bytes is unrelated from the charset, and it's only related to the notional C type that is used to model the character in the C string (e.g. `char` vs `wchar_t` and, in the latter case, whether we're on a platform where `wchar_t` is 16 or 32 bits). Which is still kicking something back to the user, but in a slightly different shape.

That said, using random charsets can still be problematic if the charset ends up encoding multiple different chars into the terminator sequence (think of a custom character whose replacement string *is* the terminator sequence :-) ). The Charset API still seems more general that what a null-terminated string API can stomach.

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

PR Comment: https://git.openjdk.org/panama-foreign/pull/836#issuecomment-1581656615


More information about the panama-dev mailing list