[foreign-memaccess+abi] RFR: 8294621: Copying from a StringCharBuffer-backed MemorySegment results in crash [v3]
Jorn Vernee
jvernee at openjdk.org
Fri Oct 14 19:15:00 UTC 2022
On Fri, 14 Oct 2022 18:36:12 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 473:
>>
>>> 471: Objects.requireNonNull(bb);
>>> 472: // StringCharBuffer is packet-private
>>> 473: if ("java.nio.StringCharBuffer".equals(bb.getClass().getName())) {
>>
>> IMHO would be better to call Buffer::isDirect, and then check if Buffer::array is == null.
>
> Nevermind, the array is not given away for read-only buffers... grrr
We get the array in the code below. I guess we can check if it's `null` there?
i.e.
if (!buffer.isDirect()) {
// heap
if (base == null) throw ...;
// wrap
}
-------------
PR: https://git.openjdk.org/panama-foreign/pull/741
More information about the panama-dev
mailing list