Class GroupLayout
- All Implemented Interfaces:
-
Constable,MemoryLayout
public final class GroupLayout extends Object implements MemoryLayout
MemoryLayout.structLayout(MemoryLayout...)); conversely, if all member layouts are laid out at the same starting offset, the resulting group layout is said to be a union (see MemoryLayout.unionLayout(MemoryLayout...)). This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail. The equals method should be used for comparisons.
Unless otherwise specified, passing a null argument, or an array argument containing one or more null elements to a method in this class causes a NullPointerException to be thrown.
- Implementation Requirements:
- This class is immutable and thread-safe.
Nested Class Summary
Nested classes/interfaces declared in interface jdk.incubator.foreign.MemoryLayout
MemoryLayout.PathElement
Field Summary
Fields declared in interface jdk.incubator.foreign.MemoryLayout
LAYOUT_NAME
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Optional<Constable> |
attribute |
Returns the attribute with the given name (if it exists). |
Stream<String> |
attributes() |
Returns a stream of the attribute names associated with this layout. |
final long |
bitAlignment() |
Returns the alignment constraint associated with this layout, expressed in bits. |
long |
bitSize() |
Computes the layout size, in bits. |
Optional<DynamicConstantDesc<GroupLayout>> |
describeConstable() |
|
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
int |
hashCode() |
Returns a hash code value for the object. |
boolean |
hasSize() |
Does this layout have a specified size? |
boolean |
isPadding() |
Is this a padding layout (e.g. a layout created from MemoryLayout.paddingLayout(long)) ? |
boolean |
isStruct() |
Is this group layout a struct? |
boolean |
isUnion() |
Is this group layout a union? |
List<MemoryLayout> |
memberLayouts() |
Returns the member layouts associated with this group. |
final Optional<String> |
name() |
Return the name (if any) associated with this layout. |
String |
toString() |
Returns a string representation of the object. |
GroupLayout |
withAttribute |
Returns a new memory layout which features the same attributes as this layout, plus the newly specified attribute. |
GroupLayout |
withBitAlignment |
Creates a new layout which features the desired alignment constraint. |
GroupLayout |
withName |
Creates a new layout which features the desired layout name. |
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface jdk.incubator.foreign.MemoryLayout
attribute, attributes, bitAlignment, bitOffset, bitOffsetHandle, bitSize, byteAlignment, byteOffset, byteOffsetHandle, byteSize, hasSize, isPadding, map, name, select, sliceHandle, varHandle
Method Details
memberLayouts
public List<MemoryLayout> memberLayouts()
- API Note:
- the order in which member layouts are returned is the same order in which member layouts have been passed to one of the group layout factory methods (see
MemoryLayout.structLayout(MemoryLayout...),MemoryLayout.unionLayout(MemoryLayout...)). - Returns:
- the member layouts associated with this group.
toString
public String toString()
Object- Specified by:
-
toStringin interfaceMemoryLayout - Overrides:
-
toStringin classObject - Returns:
- a string representation of the object.
isStruct
public boolean isStruct()
- Returns:
- true, if this group layout is a struct.
isUnion
public boolean isUnion()
- Returns:
- true, if this group layout is a union.
equals
public boolean equals(Object other)
Object The equals method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
- Specified by:
-
equalsin interfaceMemoryLayout - Parameters:
-
other- the reference object with which to compare. - Returns:
-
trueif this object is the same as the obj argument;falseotherwise. - See Also:
hashCode
public int hashCode()
ObjectHashMap. The general contract of hashCode is:
- Whenever it is invoked on the same object more than once during an execution of a Java application, the
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equalsmethod, then calling thehashCodemethod on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal according to the
equalsmethod, then calling thehashCodemethod on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
- Specified by:
-
hashCodein interfaceMemoryLayout - Returns:
- a hash code value for this object.
- See Also:
describeConstable
public Optional<DynamicConstantDesc<GroupLayout>> describeConstable()
MemoryLayoutOptional containing the nominal descriptor for this layout, if one can be constructed, or an empty Optional if one cannot be constructed.- Specified by:
-
describeConstablein interfaceConstable - Specified by:
-
describeConstablein interfaceMemoryLayout - Returns:
- An
Optionalcontaining the resulting nominal descriptor, or an emptyOptionalif one cannot be constructed.
withName
public GroupLayout withName(String name)
This is equivalent to the following code:
withAttribute(LAYOUT_NAME, name);
- Specified by:
-
withNamein interfaceMemoryLayout - Parameters:
-
name- the layout name. - Returns:
- a new layout which is the same as this layout, except for the name associated with it.
- See Also:
withBitAlignment
public GroupLayout withBitAlignment(long alignmentBits)
- Specified by:
-
withBitAlignmentin interfaceMemoryLayout - Parameters:
-
alignmentBits- the layout alignment constraint, expressed in bits. - Returns:
- a new layout which is the same as this layout, except for the alignment constraint associated with it.
withAttribute
public GroupLayout withAttribute(String name, Constable value)
- Specified by:
-
withAttributein interfaceMemoryLayout - Parameters:
-
name- the attribute name. -
value- the attribute value. - Returns:
- a new memory layout which features the same attributes as this layout, plus the newly specified attribute.
name
public final Optional<String> name()
MemoryLayoutThis is equivalent to the following code:
attribute(LAYOUT_NAME).map(String.class::cast);
- Specified by:
-
namein interfaceMemoryLayout - Returns:
- the layout name (if any).
- See Also:
attribute
public Optional<Constable> attribute(String name)
MemoryLayout- Specified by:
-
attributein interfaceMemoryLayout - Parameters:
-
name- the attribute name - Returns:
- the attribute with the given name (if it exists).
attributes
public Stream<String> attributes()
MemoryLayout- Specified by:
-
attributesin interfaceMemoryLayout - Returns:
- a stream of the attribute names associated with this layout.
bitAlignment
public final long bitAlignment()
MemoryLayoutA 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=8means unaligned (in the usual sense), which is common in packets. -
A=64means word aligned (on LP64),A=32int aligned,A=16short aligned, etc. -
A=512is the most strict alignment required by the x86/SV ABI (for AVX-512 data).
MemoryLayout.withBitAlignment(long)), then this method returns the natural alignment constraint (in bits) associated with this layout.- Specified by:
-
bitAlignmentin interfaceMemoryLayout - Returns:
- the layout alignment constraint, in bits.
hasSize
public boolean hasSize()
MemoryLayoutSequenceLayout.elementCount()). Value layouts (see ValueLayout) and padding layouts (see MemoryLayout.paddingLayout(long)) always have a specified size, therefore this method always returns true in these cases.- Specified by:
-
hasSizein interfaceMemoryLayout - Returns:
-
true, if this layout has a specified size.
bitSize
public long bitSize()
MemoryLayout- Specified by:
-
bitSizein interfaceMemoryLayout - Returns:
- the layout size, in bits.
isPadding
public boolean isPadding()
MemoryLayoutMemoryLayout.paddingLayout(long)) ?- Specified by:
-
isPaddingin interfaceMemoryLayout - Returns:
- true, if this layout is a padding layout.
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/jdk.incubator.foreign/jdk/incubator/foreign/GroupLayout.html