[foreign-memaccess+abi] RFR: 8294621: Copying from a StringCharBuffer-backed MemorySegment results in crash [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Oct 14 12:26:13 UTC 2022
On Fri, 14 Oct 2022 12:07:03 GMT, Per Minborg <duke at openjdk.org> wrote:
>> This PR prevents `StringCharBuffer` arguments in `MemorySegment::ofBuffer`.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Improve JavaDoc
src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 945:
> 943: * @throws IllegalArgumentException if the provided {@code buffer} is obtained by calling either
> 944: * ({@link CharBuffer#wrap(CharSequence)} or {@link CharBuffer#wrap(char[], int, int)}
> 945: * because these Buffer objects are not backed directly by a char array.
Suggestion:
* because these buffer objects are not backed directly by a char array.
src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 474:
> 472: // StringCharBuffer is packet-private
> 473: if ("java.nio.StringCharBuffer".equals(bb.getClass().getName())) {
> 474: throw new IllegalArgumentException("StringCharBuffer objects are not supported because they are not directly backed by a char[] array.");
Suggestion:
throw new IllegalArgumentException("The provided CharBuffer is not backed by a char[]");
test/jdk/java/foreign/TestOfBufferIssue.java line 53:
> 51: }
> 52:
> 53: }
Watch out here missing newline
-------------
PR: https://git.openjdk.org/panama-foreign/pull/741
More information about the panama-dev
mailing list