MemorySegment interface. This class contains information
about the segment's spatial and temporal bounds; each memory segment implementation is associated with an owner thread which is set at creation time.
Access to certain sensitive operations on the memory segment will fail with IllegalStateException if the
segment is either in an invalid state (e.g. it has already been closed) or if access occurs from a thread other
than the owner thread. See MemorySessionImpl for more details on management of temporal bounds. Subclasses
are defined for each memory segment kind, see NativeMemorySegmentImpl, HeapMemorySegmentImpl and
MappedMemorySegmentImpl.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final long | |
| pack-priv static final JavaNioAccess | |
| pack-priv final boolean | |
| pack-priv final MemorySessionImpl |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public MemorySegment | allocate(long byteSize, long byteAlignment)
Implements java. Returns a new memory segment with the given |
| public final ByteBuffer | asByteBuffer()
Implements java. Wraps this segment in a |
| public final Optional | asOverlappingSlice(MemorySegment other)
Implements java. Returns a slice of this segment that is the overlap between this and the provided segment. |
| public AbstractMemorySegmentImpl | asReadOnly()
Implements java. Returns a read-only view of this segment. |
| public AbstractMemorySegmentImpl | asSlice(long offset, long newSize)
Implements java. Returns a slice of this memory segment, at the given offset. |
| public AbstractMemorySegmentImpl | asSlice(long offset)
Implements java. Returns a slice of this memory segment, at the given offset. |
| public MemorySegment | asSlice(long offset, long newSize, long byteAlignment)
Implements java. Returns a slice of this memory segment, at the given offset, with the provided alignment constraint. |
| public MemorySegment | asSlice(long offset, MemoryLayout layout)
Implements java. Returns a slice of this memory segment with the given layout, at the given offset. |
| private AbstractMemorySegmentImpl | |
| private static Object | |
| private static MemorySessionImpl | |
| public final long | byteSize()
Implements java. Returns the size (in bytes) of this memory segment. |
| public void | |
| pack-priv void | |
| private int | |
| private void | |
| public final void | |
| public void | |
| pack-priv void | |
| private static Runnable | |
| public static void | copy(MemorySegment srcSegment, ValueLayout srcElementLayout, long srcOffset, MemorySegment dstSegment, ValueLayout dstElementLayout, long dstOffset, long elementCount)
Hides java. Performs a bulk copy from source segment to destination segment. |
| public static void | copy(MemorySegment srcSegment, ValueLayout srcLayout, long srcOffset, Object dstArray, int dstIndex, int elementCount)
Hides java. Copies a number of elements from a source memory segment to a destination array. |
| public static void | copy(Object srcArray, int srcIndex, MemorySegment dstSegment, ValueLayout dstLayout, long dstOffset, int elementCount)
Hides java. Copies a number of elements from a source array to a destination memory segment. |
| public static long | copy(String src, Charset dstEncoding, int srcIndex, MemorySegment dst, long dstOffset, int numChars)
Hides java. Copies the byte sequence of the given string encoded using the provided charset to the destination segment. |
| public MemorySegment | copyFrom(MemorySegment src)
Implements java. Performs a bulk copy from the given source segment to this segment. |
| pack-priv abstract AbstractMemorySegmentImpl | |
| public Stream | elements(MemoryLayout elementLayout)
Implements java. Returns a sequential |
| public boolean | equals(Object o)
Overrides java. Implements java. Compares the specified object with this memory segment for equality. |
| public final MemorySegment | fill(byte value)
Implements java. Fills the contents of this memory segment with the given value. |
| public void | force()
Implements java. Forces any changes made to the contents of this mapped segment to be written to the storage device described by the mapped segment's file descriptor. |
| public byte | get(ValueLayout.
Implements java. Reads a byte from this segment at the given offset, with the given layout. |
| public boolean | get(ValueLayout.
Implements java. Reads a boolean from this segment at the given offset, with the given layout. |
| public char | get(ValueLayout.
Implements java. Reads a char from this segment at the given offset, with the given layout. |
| public short | get(ValueLayout.
Implements java. Reads a short from this segment at the given offset, with the given layout. |
| public int | get(ValueLayout.
Implements java. Reads an int from this segment at the given offset, with the given layout. |
| public float | get(ValueLayout.
Implements java. Reads a float from this segment at the given offset, with the given layout. |
| public long | get(ValueLayout.
Implements java. Reads a long from this segment at the given offset, with the given layout. |
| public double | get(ValueLayout.
Implements java. Reads a double from this segment at the given offset, with the given layout. |
| public MemorySegment | get(AddressLayout layout, long offset)
Implements java. Reads an address from this segment at the given offset, with the given layout. |
| public byte | getAtIndex(ValueLayout.
Implements java. Reads a byte from this segment at the given index, scaled by the given layout size. |
| public boolean | getAtIndex(ValueLayout.
Implements java. Reads a boolean from this segment at the given index, scaled by the given layout size. |
| public char | getAtIndex(ValueLayout.
Implements java. Reads a char from this segment at the given index, scaled by the given layout size. |
| public short | getAtIndex(ValueLayout.
Implements java. Reads a short from this segment at the given index, scaled by the given layout size. |
| public int | getAtIndex(ValueLayout.
Implements java. Reads an int from this segment at the given index, scaled by the given layout size. |
| public float | getAtIndex(ValueLayout.
Implements java. Reads a float from this segment at the given index, scaled by the given layout size. |
| public long | getAtIndex(ValueLayout.
Implements java. Reads a long from this segment at the given index, scaled by the given layout size. |
| public double | getAtIndex(ValueLayout.
Implements java. Reads a double from this segment at the given index, scaled by the given layout size. |
| public MemorySegment | getAtIndex(AddressLayout layout, long index)
Implements java. Reads an address from this segment at the given at the given index, scaled by the given layout size. |
| public String | getString(long offset, Charset charset, long byteLength)
Implements java. Reads a string from this segment at the given offset, using the provided length and charset. |
| public String | getString(long offset)
Implements java. Reads a null-terminated string from this segment at the given offset, using the UTF-8 charset. |
| public String | getString(long offset, Charset charset)
Implements java. Reads a null-terminated string from this segment at the given offset, using the provided charset. |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this memory segment. |
| public boolean | isAccessibleBy(Thread thread)
Implements java. Returns |
| public final boolean | |
| public final boolean | |
| public boolean | isLoaded()
Implements java. Determines whether all the contents of this mapped segment are resident in physical memory. |
| public boolean | isMapped()
Implements java. Returns |
| public boolean | isNative()
Implements java. Returns |
| public boolean | isReadOnly()
Implements java. Returns |
| private static long | |
| public void | load()
Implements java. Loads the contents of this mapped segment into physical memory. |
| pack-priv abstract ByteBuffer | |
| public abstract long | |
| public long | mismatch(MemorySegment other)
Implements java. Finds and returns the offset, in bytes, of the first mismatch between this segment and the given other segment. |
| private static NativeMemorySegmentImpl | |
| private static UnsupportedOperationException | |
| public static AbstractMemorySegmentImpl | ofBuffer(Buffer b)
Hides java. Creates a memory segment that is backed by the same region of memory that backs
the given |
| private static AbstractMemorySegmentImpl | |
| private static long | |
| pack-priv boolean | |
| public final MemorySegment | reinterpret(long newSize, Arena arena, Consumer<MemorySegment> cleanup)
Implements java. Returns a new segment with the same address as this segment, but with the provided size and the provided arena's scope. |
| public final MemorySegment | reinterpret(long newSize)
Implements java. Returns a new memory segment that has the same address and scope as this segment, but with the provided size. |
| public final MemorySegment | reinterpret(Arena arena, Consumer<MemorySegment> cleanup)
Implements java. Returns a new memory segment with the same address and size as this segment, but with the provided arena's scope. |
| private NativeMemorySegmentImpl | reinterpretInternal(Class<?> callerClass, long newSize, MemorySessionImpl scope, Consumer<MemorySegment> cleanup)
|
| public MemorySessionImpl | scope()
Implements java. Returns the scope associated with this memory segment. |
| public final MemorySessionImpl | |
| public void | set(ValueLayout.
Implements java. Writes a byte into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a boolean into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a char into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a short into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes an int into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a float into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a long into this segment at the given offset, with the given layout. |
| public void | set(ValueLayout.
Implements java. Writes a double into this segment at the given offset, with the given layout. |
| public void | set(AddressLayout layout, long offset, MemorySegment value)
Implements java. Writes an address into this segment at the given offset, with the given layout. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a char into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a byte into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a boolean into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a short into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes an int into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a float into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a long into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(ValueLayout.
Implements java. Writes a double into this segment at the given index, scaled by the given layout size. |
| public void | setAtIndex(AddressLayout layout, long index, MemorySegment value)
Implements java. Writes an address into this segment at the given index, scaled by the given layout size. |
| public void | setString(long offset, String str)
Implements java. Writes the given string into this segment at the given offset, converting it to a null-terminated byte sequence using the UTF-8 charset. |
| public void | setString(long offset, String str, Charset charset)
Implements java. Writes the given string into this segment at the given offset, converting it to a null-terminated byte sequence using the provided charset. |
| public Spliterator | spliterator(MemoryLayout elementLayout)
Implements java. Returns a spliterator for this memory segment. |
| private void | |
| public final byte[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new byte array. |
| public final short[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new short array. |
| public final char[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new char array. |
| public final int[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new int array. |
| public final float[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new float array. |
| public final long[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new long array. |
| public final double[] | toArray(ValueLayout.
Implements java. Copy the contents of this memory segment into a new double array. |
| private <Z> Z | toArray(Class<Z> arrayClass, ValueLayout elemLayout, IntFunction<Z> arrayFactory, Function<Z, MemorySegment> segmentFactory)
|
| public String | |
| public void | unload()
Implements java. Unloads the contents of this mapped segment from physical memory. |
| public abstract Object | |
| public abstract long |