MemoryLayoutPREVIEW
, ValueLayoutPREVIEW
public sealed interface AddressLayout extends ValueLayoutPREVIEW
AddressLayout
is a preview API of the Java platform. MemorySegment.class
. The size and alignment of an address layout are platform-dependent (e.g. on a 64-bit platform, the size and alignment of an address layout are set to 8 bytes). An address layout may optionally feature a target layout. An address layout with target layout T
can be used to model the address of a region of memory whose layout is T
. For instance, an address layout with target layout ValueLayout.JAVA_INT
PREVIEW can be used to model the address of a region of memory that is 4 bytes long. Specifying a target layout can be useful in the following situations:
MemorySegment.getAtIndex(AddressLayout, long)
PREVIEW;Linker.downcallHandle(FunctionDescriptor, Option...)
PREVIEW; Linker.upcallStub(MethodHandle, FunctionDescriptor, Arena, Option...)
PREVIEW. MemoryLayout.PathElementPREVIEW
ValueLayout.OfBooleanPREVIEW, ValueLayout.OfBytePREVIEW, ValueLayout.OfCharPREVIEW, ValueLayout.OfDoublePREVIEW, ValueLayout.OfFloatPREVIEW, ValueLayout.OfIntPREVIEW, ValueLayout.OfLongPREVIEW, ValueLayout.OfShortPREVIEW
ADDRESS, ADDRESS_UNALIGNED, JAVA_BOOLEAN, JAVA_BYTE, JAVA_CHAR, JAVA_CHAR_UNALIGNED, JAVA_DOUBLE, JAVA_DOUBLE_UNALIGNED, JAVA_FLOAT, JAVA_FLOAT_UNALIGNED, JAVA_INT, JAVA_INT_UNALIGNED, JAVA_LONG, JAVA_LONG_UNALIGNED, JAVA_SHORT, JAVA_SHORT_UNALIGNED
Modifier and Type | Method | Description |
---|---|---|
Optional |
targetLayout() |
Returns the target layout associated with this address layout (if any). |
AddressLayoutPREVIEW |
withByteAlignment |
Returns a memory layout with the same characteristics as this layout, but with the given alignment constraint (in bytes). |
AddressLayoutPREVIEW |
withName |
Returns a memory layout with the same characteristics as this layout, but with the given name. |
AddressLayoutPREVIEW |
withOrder |
Returns a value layout with the same characteristics as this layout, but with the given byte order. |
AddressLayoutPREVIEW |
withoutName() |
Returns a memory layout with the same characteristics as this layout, but with no name. |
AddressLayoutPREVIEW |
withoutTargetLayout() |
Returns an address layout with the same carrier, alignment constraint, name and order as this address layout, but with no target layout. |
AddressLayoutPREVIEW |
withTargetLayout |
Returns an address layout with the same carrier, alignment constraint, name and order as this address layout, but associated with the specified target layout. |
byteAlignment, byteOffset, byteOffsetHandle, byteSize, equals, hashCode, name, select, sliceHandle, toString, varHandle
arrayElementVarHandle, carrier, order
AddressLayoutPREVIEW withName(String name)
withName
in interface MemoryLayoutPREVIEW
withName
in interface ValueLayoutPREVIEW
name
- the layout name.AddressLayoutPREVIEW withoutName()
withoutName
in interface MemoryLayoutPREVIEW
withoutName
in interface ValueLayoutPREVIEW
AddressLayoutPREVIEW withByteAlignment(long byteAlignment)
withByteAlignment
in interface MemoryLayoutPREVIEW
withByteAlignment
in interface ValueLayoutPREVIEW
byteAlignment
- the layout alignment constraint, expressed in bytes.AddressLayoutPREVIEW withOrder(ByteOrder order)
withOrder
in interface ValueLayoutPREVIEW
order
- the desired byte order.AddressLayoutPREVIEW withTargetLayout(MemoryLayoutPREVIEW layout)
AddressLayout addressLayout = ...
AddressLayout unboundedLayout = addressLayout.withTargetLayout(
MemoryLayout.sequenceLayout(ValueLayout.JAVA_BYTE));
This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
layout
- the target layout.IllegalCallerException
- If the caller is in a module that does not have native access enabled.AddressLayoutPREVIEW withoutTargetLayout()
Optional<MemoryLayoutPREVIEW> targetLayout()
© 1993, 2023, 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/21/docs/api/java.base/java/lang/foreign/AddressLayout.html
AddressLayout
when preview features are enabled.