On Fri, 16 Oct 2026 11:51:44 GMT, Maurizio Cimadamore <[email protected]> wrote:
>> Currently the javadoc of Linker has many examples that use the `JAVA_*` >> layout constants. >> >> It is preferred for users to use the canonical layouts the linker returns, >> since they have a much more obvious mapping to native types, and are >> guaranteed to work. >> >> This patch tweaks the examples to be written in terms of canonical layouts >> rather than the `JAVA_*` constants. It adds a missing column to the table of >> example types that lists their canonical layout name (which doesn't match >> the C type name for `void*`). >> >> Since this is a doc clarification, no CSR is needed. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > src/java.base/share/classes/java/lang/foreign/Linker.java line 372: > >> 370: * MemorySegment array = arena.allocateFrom(C_INT, 0, 9, 3, 4, 6, >> 5, 1, 8, 2, 7); >> 371: * qsort.invokeExact(array, 10L, 4L, comparFunc); >> 372: * int[] sorted = array.toArray(ValueLayout.JAVA_INT); // [ 0, 1, >> 2, 3, 4, 5, 6, 7, 8, 9 ] > > This is a bit subtle -- but I think it's ok Actually, after double-checking the javadoc, the layout passed to `toArray` is the source element layout, so this should be `C_INT` as well. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33411#discussion_r4294376812
