[foreign-memaccess+abi] RFR: 8294621: Copying from a StringCharBuffer-backed MemorySegment results in crash

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Oct 14 11:47:22 UTC 2022


On Fri, 14 Oct 2022 11:32:19 GMT, Per Minborg <duke at openjdk.org> wrote:

> This PR prevents `StringCharBuffer` arguments in `MemorySegment::ofBuffer`.

src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 942:

> 940:      * @param buffer the buffer instance to be turned into a new memory segment.
> 941:      * @return a memory segment, derived from the given buffer instance.
> 942:      * @throws IllegalArgumentException if the provided {@code buffer} is a StringCharBuffer.

Note that StringCharBuffer is not a public API type. It is something we create with `CharBuffer,wrap(CharSequence)` so the doc should reflect that.

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

PR: https://git.openjdk.org/panama-foreign/pull/741


More information about the panama-dev mailing list