RFR: 8291359: Specification of method j.l.foreign.VaList::skip still deserves clarification [v4]

Jorn Vernee jvernee at openjdk.org
Fri Dec 2 20:34:32 UTC 2022


On Fri, 2 Dec 2022 20:21:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/foreign/VaList.java line 55:
>> 
>>> 53:  * and any other type that fits into a {@code long}.
>>> 54:  * <h2 id="safety">Safety considerations</h2>
>>> 55:  * Accessing a value through a variable argument list using the wrong memory layout will result in undefined behavior.
>> 
>> Note that I went with "through" here, instead of "in", since we describe a va list as a "stateful cursor used to iterate over a set of arguments" in the section before this.
>
> I think we can condense this:
> 
> 
>  For instance, if a variable argument list currently points at a C {@code int} value, then accessing it using
>  * {@link #nextVarg(ValueLayout.OfLong)} is illegal. Similarly, accessing the variable argument list with  {@link #skip(MemoryLayout...)}, and providing a layout other than {@link ValueLayout.OfInt} is illegal. Any such illegal accesses might not be detected by the implementation, and can corrupt the variable argument list, so that the behavior of subsequent accesses is also undefined.
>  ```

Done

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

PR: https://git.openjdk.org/jdk/pull/11440


More information about the core-libs-dev mailing list