Skip to content

Commit 562bc17

Browse files
committed
8291359: Specification of method j.l.foreign.VaList::skip still deserves clarification
Reviewed-by: mcimadamore
1 parent 2821fa9 commit 562bc17

File tree

1 file changed

+7
-0
lines changed
  • src/java.base/share/classes/java/lang/foreign

1 file changed

+7
-0
lines changed

src/java.base/share/classes/java/lang/foreign/VaList.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
* As such, this interface only supports reading {@code int}, {@code double},
5353
* and any other type that fits into a {@code long}.
5454
* <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.
56+
* For instance, if a variable argument list currently points at a C {@code int} value, then accessing it using
57+
* {@link #nextVarg(ValueLayout.OfLong)} is illegal. Similarly, accessing the variable argument list with
58+
* {@link #skip(MemoryLayout...)}, and providing a layout other than {@link ValueLayout.OfInt} is illegal.
59+
* Any such illegal accesses might not be detected by the implementation, and can corrupt the variable argument list,
60+
* so that the behavior of subsequent accesses is also undefined.
61+
* <p>
5562
* It is possible for clients to access elements outside the spatial bounds of a variable argument list.
5663
* Variable argument list implementations will try to detect out-of-bounds reads on a best-effort basis.
5764
* <p>

0 commit comments

Comments
 (0)