8291359: Specification of method j.l.foreign.VaList::skip still deserves clarification

Reviewed-by: mcimadamore
This commit is contained in:
Jorn Vernee 2022-12-02 22:15:27 +00:00
parent 2821fa9883
commit 562bc171b9

View File

@ -52,6 +52,13 @@ import jdk.internal.reflect.Reflection;
* As such, this interface only supports reading {@code int}, {@code double},
* and any other type that fits into a {@code long}.
* <h2 id="safety">Safety considerations</h2>
* Accessing a value through a variable argument list using the wrong memory layout will result in undefined behavior.
* 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.
* <p>
* It is possible for clients to access elements outside the spatial bounds of a variable argument list.
* Variable argument list implementations will try to detect out-of-bounds reads on a best-effort basis.
* <p>