APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.foreign

public Class LayoutPath

extends Object
Class Inheritance
Imports
jdk.internal.vm.annotation.ForceInline, java.lang.foreign.AddressLayout, .GroupLayout, .MemoryLayout, .MemorySegment, .SequenceLayout, .StructLayout, .ValueLayout, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, .VarHandle, java.util.Arrays, .Objects, java.util.function.UnaryOperator, java.util.stream.IntStream, .Stream

This class provide support for constructing layout paths; that is, starting from a root path (see rootPath(MemoryLayout)), a path can be constructed by selecting layout elements using the selector methods provided by this class (see sequenceElement(), sequenceElement(long), sequenceElement(long, long), groupElement(String)). Once a path has been fully constructed, clients can ask for the offset associated with the layout element selected by the path (see offset), or obtain var handle to access the selected layout element given an address pointing to a segment associated with the root layout (see dereferenceHandle()).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record
public static record
public static record
public static record
public static record
public static record

Field Summary

Modifier and TypeField and Description
private final long[]
private final MethodHandle[]
private static final long[]
private static final MethodHandle[]
public static final MemoryLayout.PathElement[]
private static final long[]
private final LayoutPath
private final MemoryLayout
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
private final long
private final long[]

Constructor Summary

AccessConstructor and Description
private
LayoutPath(MemoryLayout layout, long offset, long[] strides, long[] bounds, MethodHandle[] derefAdapters, LayoutPath enclosing)

Method Summary

Modifier and TypeMethod and Description
private long[]
addBound(long maxIndex)

private static long
addScaledOffset(long base, long index, long stride, long bound)

private long[]
addStride(long stride)

private static IllegalArgumentException
private static void
checkEnclosingLayout(MemorySegment segment, long offset, MemoryLayout enclosing)

private void
public LayoutPath
public VarHandle
public VarHandle
dereferenceHandle(boolean adapt)

private static LayoutPath
public LayoutPath
public LayoutPath
groupElement(long index)

public MemoryLayout
private static LayoutPath
nestedPath(MemoryLayout layout, long offset, long[] strides, long[] bounds, MethodHandle[] derefAdapters, LayoutPath encl)

public long
public MethodHandle
private GroupLayout
private <T extends MemoryLayout> T
requireLayoutType(Class<T> layoutClass, String name)

private SequenceLayout
private static MemorySegment
private MemoryLayout
public static LayoutPath
public LayoutPath
public LayoutPath
sequenceElement(long start, long step)

public LayoutPath
sequenceElement(long index)

public MethodHandle
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundsback to summary
private final long[] bounds
derefAdaptersback to summary
private final MethodHandle[] derefAdapters
EMPTY_BOUNDSback to summary
private static final long[] EMPTY_BOUNDS
EMPTY_DEREF_HANDLESback to summary
private static final MethodHandle[] EMPTY_DEREF_HANDLES
EMPTY_PATH_ELEMENTSback to summary
public static final MemoryLayout.PathElement[] EMPTY_PATH_ELEMENTS
EMPTY_STRIDESback to summary
private static final long[] EMPTY_STRIDES
enclosingback to summary
private final LayoutPath enclosing
layoutback to summary
private final MemoryLayout layout
MH_ADD_EXACTback to summary
private static final MethodHandle MH_ADD_EXACT
MH_ADD_SCALED_OFFSETback to summary
private static final MethodHandle MH_ADD_SCALED_OFFSET
MH_CHECK_ENCL_LAYOUTback to summary
private static final MethodHandle MH_CHECK_ENCL_LAYOUT
MH_SEGMENT_RESIZEback to summary
private static final MethodHandle MH_SEGMENT_RESIZE
MH_SLICEback to summary
private static final MethodHandle MH_SLICE
MH_SLICE_LAYOUTback to summary
private static final MethodHandle MH_SLICE_LAYOUT
offsetback to summary
private final long offset
stridesback to summary
private final long[] strides

Constructor Detail

LayoutPathback to summary
private LayoutPath(MemoryLayout layout, long offset, long[] strides, long[] bounds, MethodHandle[] derefAdapters, LayoutPath enclosing)

Method Detail

addBoundback to summary
private long[] addBound(long maxIndex)
addScaledOffsetback to summary
private static long addScaledOffset(long base, long index, long stride, long bound)
Annotations
@ForceInline
addStrideback to summary
private long[] addStride(long stride)
badLayoutPathback to summary
private static IllegalArgumentException badLayoutPath(String cause)
checkEnclosingLayoutback to summary
private static void checkEnclosingLayout(MemorySegment segment, long offset, MemoryLayout enclosing)
checkSequenceBoundsback to summary
private void checkSequenceBounds(SequenceLayout seq, long index)
derefElementback to summary
public LayoutPath derefElement()
dereferenceHandleback to summary
public VarHandle dereferenceHandle()
dereferenceHandleback to summary
public VarHandle dereferenceHandle(boolean adapt)
derefPathback to summary
private static LayoutPath derefPath(MemoryLayout layout, MethodHandle handle, LayoutPath encl)
groupElementback to summary
public LayoutPath groupElement(String name)
groupElementback to summary
public LayoutPath groupElement(long index)
layoutback to summary
public MemoryLayout layout()
nestedPathback to summary
private static LayoutPath nestedPath(MemoryLayout layout, long offset, long[] strides, long[] bounds, MethodHandle[] derefAdapters, LayoutPath encl)
offsetback to summary
public long offset()
offsetHandleback to summary
public MethodHandle offsetHandle()
requireGroupLayoutback to summary
private GroupLayout requireGroupLayout()
requireLayoutTypeback to summary
private <T extends MemoryLayout> T requireLayoutType(Class<T> layoutClass, String name)
requireSequenceLayoutback to summary
private SequenceLayout requireSequenceLayout()
resizeSegmentback to summary
private static MemorySegment resizeSegment(MemorySegment segment)
rootLayoutback to summary
private MemoryLayout rootLayout()
rootPathback to summary
public static LayoutPath rootPath(MemoryLayout layout)
sequenceElementback to summary
public LayoutPath sequenceElement()
sequenceElementback to summary
public LayoutPath sequenceElement(long start, long step)
sequenceElementback to summary
public LayoutPath sequenceElement(long index)
sliceHandleback to summary
public MethodHandle sliceHandle()
jdk.internal.foreign back to summary

public final Record LayoutPath.DereferenceElement

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
no record components

Field Summary

Modifier and TypeField and Description
private static final LayoutPath.DereferenceElement

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public static MemoryLayout.PathElement
public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

INSTANCEback to summary
private static final LayoutPath.DereferenceElement INSTANCE

Constructor Detail

DereferenceElementback to summary
public DereferenceElement()

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Annotations
@Override
instanceback to summary
public static MemoryLayout.PathElement instance()
toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override
jdk.internal.foreign back to summary

public final Record LayoutPath.GroupElementByIndex

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
index:long 

Field Summary

Modifier and TypeField and Description
private final long
index

Record Component accessed by index().

Constructor Summary

AccessConstructor and Description
public
GroupElementByIndex(long index)

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public long
index()

Record Component getter of index.

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

indexback to summary
private final long index

Record Component accessed by index().

Constructor Detail

GroupElementByIndexback to summary
public GroupElementByIndex(long index)

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

indexback to summary
public long index()

Record Component getter of index.

toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override
jdk.internal.foreign back to summary

public final Record LayoutPath.GroupElementByName

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
name:String 

Field Summary

Modifier and TypeField and Description
private final String
name

Record Component accessed by name().

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
name()

Record Component getter of name.

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

nameback to summary
private final String name

Record Component accessed by name().

Constructor Detail

GroupElementByNameback to summary
public GroupElementByName(String name)

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

nameback to summary
public String name()

Record Component getter of name.

toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override
jdk.internal.foreign back to summary

public final Record LayoutPath.SequenceElement

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
no record components

Field Summary

Modifier and TypeField and Description
private static final LayoutPath.SequenceElement

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public static MemoryLayout.PathElement
public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

INSTANCEback to summary
private static final LayoutPath.SequenceElement INSTANCE

Constructor Detail

SequenceElementback to summary
public SequenceElement()

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

instanceback to summary
public static MemoryLayout.PathElement instance()
toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override
jdk.internal.foreign back to summary

public final Record LayoutPath.SequenceElementByIndex

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
index:long 

Field Summary

Modifier and TypeField and Description
private final long
index

Record Component accessed by index().

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public long
index()

Record Component getter of index.

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

indexback to summary
private final long index

Record Component accessed by index().

Constructor Detail

SequenceElementByIndexback to summary
public SequenceElementByIndex(long index)

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

indexback to summary
public long index()

Record Component getter of index.

toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override
jdk.internal.foreign back to summary

public final Record LayoutPath.SequenceElementByRange

extends Record
implements PathElement, UnaryOperator<LayoutPath>
Class Inheritance
All Implemented Interfaces
java.util.function.UnaryOperator, java.util.function.Function, java.lang.foreign.MemoryLayout.PathElement
Record Components
start:long 
step:long 

Field Summary

Modifier and TypeField and Description
private final long
start

Record Component accessed by start().

private final long
step

Record Component accessed by step().

Constructor Summary

AccessConstructor and Description
public
SequenceElementByRange(long start, long step)

Method Summary

Modifier and TypeMethod and Description
public LayoutPath
apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public long
start()

Record Component getter of start.

public long
step()

Record Component getter of step.

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

startback to summary
private final long start

Record Component accessed by start().

stepback to summary
private final long step

Record Component accessed by step().

Constructor Detail

SequenceElementByRangeback to summary
public SequenceElementByRange(long start, long step)

Method Detail

applyback to summary
public LayoutPath apply(LayoutPath layoutPath)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Annotations
@Override
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

startback to summary
public long start()

Record Component getter of start.

stepback to summary
public long step()

Record Component getter of step.

toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Annotations
@Override