[foreign-abi] RFR: 8247488: Add support for string helpers in CSupport

Henry Jen henryjen at openjdk.java.net
Fri Jun 12 17:03:02 UTC 2020


On Fri, 12 Jun 2020 15:09:55 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This is a relatively straightforward patch, which takes some of the code which jextract generates to help with string
> conversion to/from Java and puts it into the recently added CSupport class.

Other than the mix-up java doc, seems good to me.

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java line 539:

> 538:      * new native memory segment.
> 539:      * <p>
> 540:      * This method always replaces malformed-input and unmappable-character

The comment seems to mixed up with toCString(String, Charset) method

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java line 557:

> 556:      * platform's default charset, storing the result into a new native memory segment.
> 557:      * <p>
> 558:      * This method always replaces malformed-input and unmappable-character

Given charset

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java line 576:

> 575:      * Convert a Java string into a null-terminated C string, using the given
> 576:      * {@linkplain java.nio.charset.Charset charset}, storing the result into a
> 577:      * native memory segment allocated using the provided scope.

Default charset

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java line 597:

> 596:      * platform's default charset, storing the result into a new native memory segment
> 597:      * native memory segment allocated using the provided scope.
> 598:      * <p>

given

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

Changes requested by henryjen (Committer).

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


More information about the panama-dev mailing list