ValueLayout is a preview API of the Java platform.
Programs can only use ValueLayout when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A value layout. A value layout is used to model the memory layout associated with values of basic data types, such as integral types (either signed or unsigned) and floating-point types. Each value layout has a size, an alignment (in bits), a byte order , and a carrier, that is, the Java type that should be used when accessingPREVIEW a memory region using the value layout.
This class defines useful value layout constants for Java primitive types and addresses. The layout constants in this class make implicit alignment and byte-ordering assumption: all layout constants in this class are byte-aligned, and their byte order is set to the platform default , thus making it easy to work with other APIs, such as arrays and ByteBuffer.
Since:
19
Implementation Requirements:
This class and its subclasses are immutable, thread-safe and value-based.
A value layout constant whose size is the same as that of a machine address (size_t), bit alignment set to sizeof(size_t) * 8 , and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java byte, bit alignment set to 8, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java boolean, bit alignment set to 8, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java char, bit alignment set to 16, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java short, bit alignment set to 16, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java int, bit alignment set to 32, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java long, bit alignment set to 64, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java float, bit alignment set to 32, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
A value layout constant whose size is the same as that of a Java double, bit alignment set to 64, and byte order set to ByteOrder.nativeOrder(). Equivalent to the following code:
Compares the specified object with this layout for equality. Returns true if and only if the specified object is also a layout, and it is equal to this layout. Two layouts are considered equal if they are of the same kind, have the same size, name and alignment constraints. Furthermore, depending on the layout kind, additional conditions must be satisfied:
two value layouts are considered equal if they have the same byte order (see order())
Creates a strided access var handle that can be used to dereference a multi-dimensional array. The layout of this array is a sequence layout with shape.length nested sequence layouts. The element layout of the sequence layout at depth shape.length is this value layout. As a result, if shape.length == 0 , the array layout will feature only one dimension.
The resulting var handle will feature sizes.length + 1 coordinates of type long, which are used as indices into a multi-dimensional array.
The resulting var handle arrayHandle will feature 3 coordinates of type long; each coordinate is interpreted as an index into the corresponding sequence layout. If we refer to the var handle coordinates, from left to right, as x, y and z respectively, the final offset dereferenced by the var handle can be computed with the following formula:
Returns the alignment constraint associated with this layout, expressed in bits. Layout alignment defines a power of two A which is the bit-wise alignment of the layout. If A <= 8 then A/8 is the number of bytes that must be aligned for any pointer that correctly points to this layout. Thus:
A=8 means unaligned (in the usual sense), which is common in packets.
A=64 means word aligned (on LP64), A=32 int aligned, A=16 short aligned, etc.
A=512 is the most strict alignment required by the x86/SV ABI (for AVX-512 data).
ValueLayout
when preview features are enabled.