[foreign-abi] RFR: 8247488: Add support for string helpers in CSupport (decoding support)
Jorn Vernee
jvernee at openjdk.java.net
Mon Jun 15 20:15:46 UTC 2020
On Mon, 15 Jun 2020 18:20:31 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch add more symmetric support for charset-driven decoding of the contents of a native string.
> That means we can no longer using a StringBuilder, but, instead, we have to get the byte array and create a `String`
> out of that using specified `Charset` instance.
> Implementation-wise, following an offline discussion with Jorn, I've settled for an approach which finds string length,
> then does a bulk copy to a byte array. Not sure this is going to peform well on small strings. The alternative would
> have been to use `ByteArrayOutputStream` - but the issue there is that both `write` and `toString` methods there are
> `synchronized`. In any case, I think the implementation can be made more efficient later, if we find that to be an
> issue.
Marked as reviewed by jvernee (Committer).
src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java line 669:
> 668: * This method is <em>restricted</em>. Restricted method are unsafe, and, if used incorrectly, their use might
> crash 669: * the JVM crash or, worse, silently result in memory corruption. Thus, clients should refrain from
> depending on 670: * restricted methods, and use safe and supported functionalities, where possible.
Seems like a typo: "their use might crash the JVM crash"
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/207
More information about the panama-dev
mailing list