# Uses of Interface
java.lang.foreign.MemorySegment

Packages that use MemorySegmentPREVIEW
Package
Description
java.lang.foreign
Provides low-level access to memory and functions outside the Java runtime.
java.nio.channels
Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.
jdk.incubator.vector
Incubating Feature. Will be removed in a future release.

- ## Uses of MemorySegmentPREVIEW in java.lang.foreign

  Fields in java.lang.foreign declared as MemorySegmentPREVIEW
  Modifier and Type
  Field
  Description
  `static final MemorySegmentPREVIEW`
  MemorySegment.`NULL`
  A zero-length native segment modelling the `NULL` address.
  Methods in java.lang.foreign that return MemorySegmentPREVIEW
  Modifier and Type
  Method
  Description
  `default MemorySegmentPREVIEW`
  Arena.`allocate(long byteSize, long byteAlignment)`
  Returns a native memory segment with the given size (in bytes) and alignment constraint (in bytes).
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(long byteSize)`
  Allocates a memory segment with the given size.
  `MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(long byteSize, long byteAlignment)`
  Allocates a memory segment with the given size and alignment constraint.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(MemoryLayoutPREVIEW layout)`
  Allocates a memory segment with the given layout.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfAddressPREVIEW layout, MemorySegmentPREVIEW value)`
  Allocates a memory segment with the given layout and initializes it with the given address value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfBytePREVIEW layout, byte value)`
  Allocates a memory segment with the given layout and initializes it with the given byte value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfCharPREVIEW layout, char value)`
  Allocates a memory segment with the given layout and initializes it with the given char value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfDoublePREVIEW layout, double value)`
  Allocates a memory segment with the given layout and initializes it with the given double value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfFloatPREVIEW layout, float value)`
  Allocates a memory segment with the given layout and initializes it with the given float value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfIntPREVIEW layout, int value)`
  Allocates a memory segment with the given layout and initializes it with the given int value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfLongPREVIEW layout, long value)`
  Allocates a memory segment with the given layout and initializes it with the given long value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfShortPREVIEW layout, short value)`
  Allocates a memory segment with the given layout and initializes it with the given short value.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(MemoryLayoutPREVIEW elementLayout, long count)`
  Allocates a memory segment with the given element layout and size.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfBytePREVIEW elementLayout, byte... elements)`
  Allocates a memory segment with the given layout and initializes it with the given byte elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfCharPREVIEW elementLayout, char... elements)`
  Allocates a memory segment with the given layout and initializes it with the given char elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfDoublePREVIEW elementLayout, double... elements)`
  Allocates a memory segment with the given layout and initializes it with the given double elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfFloatPREVIEW elementLayout, float... elements)`
  Allocates a memory segment with the given layout and initializes it with the given float elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfIntPREVIEW elementLayout, int... elements)`
  Allocates a memory segment with the given layout and initializes it with the given int elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfLongPREVIEW elementLayout, long... elements)`
  Allocates a memory segment with the given layout and initializes it with the given long elements.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateArray(ValueLayout.OfShortPREVIEW elementLayout, short... elements)`
  Allocates a memory segment with the given layout and initializes it with the given short elements.
  `static MemorySegmentPREVIEW`
  MemorySegment.`allocateNative(long byteSize, long byteAlignment, SegmentScopePREVIEW scope)`
  Creates a native segment with the given size (in bytes), alignment (in bytes) and scope.
  `static MemorySegmentPREVIEW`
  MemorySegment.`allocateNative(long byteSize, SegmentScopePREVIEW scope)`
  Creates a native segment with the given size (in bytes) and scope.
  `static MemorySegmentPREVIEW`
  MemorySegment.`allocateNative(MemoryLayoutPREVIEW layout, SegmentScopePREVIEW scope)`
  Creates a native segment with the given layout and scope.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocateUtf8String(String str)`
  Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a memory segment.
  `MemorySegmentPREVIEW`
  MemorySegment.`asReadOnly()`
  Returns a read-only view of this segment.
  `default MemorySegmentPREVIEW`
  MemorySegment.`asSlice(long offset)`
  Returns a slice of this memory segment, at the given offset.
  `MemorySegmentPREVIEW`
  MemorySegment.`asSlice(long offset, long newSize)`
  Returns a slice of this memory segment, at the given offset.
  `default MemorySegmentPREVIEW`
  MemorySegment.`copyFrom(MemorySegmentPREVIEW src)`
  Performs a bulk copy from given source segment to this segment.
  `MemorySegmentPREVIEW`
  MemorySegment.`fill(byte value)`
  Fills a value into this memory segment.
  `default MemorySegmentPREVIEW`
  MemorySegment.`get(ValueLayout.OfAddressPREVIEW layout, long offset)`
  Reads an address from this segment at the given offset, with the given layout.
  `default MemorySegmentPREVIEW`
  MemorySegment.`getAtIndex(ValueLayout.OfAddressPREVIEW layout, long index)`
  Reads an address from this segment at the given at the given index, scaled by the given layout size.
  `MemorySegmentPREVIEW`
  VaList.`nextVarg(GroupLayoutPREVIEW layout, SegmentAllocatorPREVIEW allocator)`
  Reads the next composite value into a new `MemorySegment`, allocated with the provided allocator, and advances this variable argument list's position.
  `MemorySegmentPREVIEW`
  VaList.`nextVarg(ValueLayout.OfAddressPREVIEW layout)`
  Reads the next address value, wraps it into a native segment, and advances this variable argument list's position.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofAddress(long address)`
  Creates a zero-length native segment from the given address valuePREVIEW.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofAddress(long address, long byteSize)`
  Creates a native segment with the given size and address valuePREVIEW.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofAddress(long address, long byteSize, SegmentScopePREVIEW scope)`
  Creates a native segment with the given size, address, and scope.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofAddress(long address, long byteSize, SegmentScopePREVIEW scope, Runnable cleanupAction)`
  Creates a native segment with the given size, address, and scope.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(byte[] byteArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given byte array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(char[] charArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given char array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(double[] doubleArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given double array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(float[] floatArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given float array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(int[] intArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given int array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(long[] longArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given long array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofArray(short[] shortArray)`
  Creates a heap segment backed by the on-heap region of memory that holds the given short array.
  `static MemorySegmentPREVIEW`
  MemorySegment.`ofBuffer(Buffer buffer)`
  Creates a memory segment that is backed by the same region of memory that backs the given `Buffer` instance.
  `MemorySegmentPREVIEW`
  VaList.`segment()`
  Returns a zero-length memory segmentPREVIEW associated with this variable argument list.
  `MemorySegmentPREVIEW`
  Linker.`upcallStub(MethodHandle target, FunctionDescriptorPREVIEW function, SegmentScopePREVIEW scope)`
  Creates a stub which can be passed to other foreign functions as a function pointer, associated with the given scope.
  Methods in java.lang.foreign that return types with arguments of type MemorySegmentPREVIEW
  Modifier and Type
  Method
  Description
  `Optional<MemorySegmentPREVIEW>`
  MemorySegment.`asOverlappingSlice(MemorySegmentPREVIEW other)`
  Returns a slice of this segment that is the overlap between this and the provided segment.
  `Stream<MemorySegmentPREVIEW>`
  MemorySegment.`elements(MemoryLayoutPREVIEW elementLayout)`
  Returns a sequential `Stream` over disjoint slices (whose size matches that of the specified layout) in this segment.
  `Optional<MemorySegmentPREVIEW>`
  SymbolLookup.`find(String name)`
  Returns the address of the symbol with the given name.
  `Spliterator<MemorySegmentPREVIEW>`
  MemorySegment.`spliterator(MemoryLayoutPREVIEW elementLayout)`
  Returns a spliterator for this memory segment.
  Methods in java.lang.foreign with parameters of type MemorySegmentPREVIEW
  Modifier and Type
  Method
  Description
  `VaList.BuilderPREVIEW`
  VaList.Builder.`addVarg(GroupLayoutPREVIEW layout, MemorySegmentPREVIEW value)`
  Writes a `MemorySegment`, with the given layout, to the variable argument list being constructed.
  `VaList.BuilderPREVIEW`
  VaList.Builder.`addVarg(ValueLayout.OfAddressPREVIEW layout, MemorySegmentPREVIEW segment)`
  Writes the addressPREVIEW of the provided native segment to the variable argument list being constructed.
  `default MemorySegmentPREVIEW`
  SegmentAllocator.`allocate(ValueLayout.OfAddressPREVIEW layout, MemorySegmentPREVIEW value)`
  Allocates a memory segment with the given layout and initializes it with the given address value.
  `Optional<MemorySegmentPREVIEW>`
  MemorySegment.`asOverlappingSlice(MemorySegmentPREVIEW other)`
  Returns a slice of this segment that is the overlap between this and the provided segment.
  `static void`
  MemorySegment.`copy(MemorySegmentPREVIEW srcSegment, long srcOffset, MemorySegmentPREVIEW dstSegment, long dstOffset, long bytes)`
  Performs a bulk copy from source segment to destination segment.
  `static void`
  MemorySegment.`copy(MemorySegmentPREVIEW srcSegment, ValueLayoutPREVIEW srcElementLayout, long srcOffset, MemorySegmentPREVIEW dstSegment, ValueLayoutPREVIEW dstElementLayout, long dstOffset, long elementCount)`
  Performs a bulk copy from source segment to destination segment.
  `static void`
  MemorySegment.`copy(MemorySegmentPREVIEW srcSegment, ValueLayoutPREVIEW srcLayout, long srcOffset, Object dstArray, int dstIndex, int elementCount)`
  Copies a number of elements from a source memory segment to a destination array.
  `static void`
  MemorySegment.`copy(Object srcArray, int srcIndex, MemorySegmentPREVIEW dstSegment, ValueLayoutPREVIEW dstLayout, long dstOffset, int elementCount)`
  Copies a number of elements from a source array to a destination memory segment.
  `default MemorySegmentPREVIEW`
  MemorySegment.`copyFrom(MemorySegmentPREVIEW src)`
  Performs a bulk copy from given source segment to this segment.
  `default MethodHandle`
  Linker.`downcallHandle(MemorySegmentPREVIEW symbol, FunctionDescriptorPREVIEW function, Linker.OptionPREVIEW... options)`
  Creates a method handle which can be used to call a foreign function with the given signature and address.
  `default long`
  MemorySegment.`mismatch(MemorySegmentPREVIEW other)`
  Finds and returns the offset, in bytes, of the first mismatch between this segment and the given other segment.
  `static long`
  MemorySegment.`mismatch(MemorySegmentPREVIEW srcSegment, long srcFromOffset, long srcToOffset, MemorySegmentPREVIEW dstSegment, long dstFromOffset, long dstToOffset)`
  Finds and returns the relative offset, in bytes, of the first mismatch between the source and the destination segments.
  `static SegmentAllocatorPREVIEW`
  SegmentAllocator.`prefixAllocator(MemorySegmentPREVIEW segment)`
  Returns a segment allocator which responds to allocation requests by recycling a single segment.
  `long`
  MemorySegment.`segmentOffset(MemorySegmentPREVIEW other)`
  Returns the offset, in bytes, of the provided segment, relative to this segment.
  `default void`
  MemorySegment.`set(ValueLayout.OfAddressPREVIEW layout, long offset, MemorySegmentPREVIEW value)`
  Writes an address into this segment at the given offset, with the given layout.
  `default void`
  MemorySegment.`setAtIndex(ValueLayout.OfAddressPREVIEW layout, long index, MemorySegmentPREVIEW value)`
  Writes an address into this segment at the given index, scaled by the given layout size.
  `static SegmentAllocatorPREVIEW`
  SegmentAllocator.`slicingAllocator(MemorySegmentPREVIEW segment)`
  Returns a segment allocator which responds to allocation requests by returning consecutive slices obtained from the provided segment.

- ## Uses of MemorySegmentPREVIEW in java.nio.channels

  Methods in java.nio.channels that return MemorySegmentPREVIEW
  Modifier and Type
  Method
  Description
  `MemorySegmentPREVIEW`
  FileChannel.`map(FileChannel.MapMode mode, long offset, long size, SegmentScopePREVIEW session)`
  Preview.
  Maps a region of this channel's file into a new mapped memory segment, with the given offset, size and memory session.

- ## Uses of MemorySegmentPREVIEW in jdk.incubator.vector

  Methods in jdk.incubator.vector with parameters of type MemorySegmentPREVIEW
  Modifier and Type
  Method
  Description
  `static ByteVector`
  ByteVector.`fromMemorySegment(VectorSpecies<Byte> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static ByteVector`
  ByteVector.`fromMemorySegment(VectorSpecies<Byte> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Byte> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `static DoubleVector`
  DoubleVector.`fromMemorySegment(VectorSpecies<Double> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static DoubleVector`
  DoubleVector.`fromMemorySegment(VectorSpecies<Double> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Double> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `static FloatVector`
  FloatVector.`fromMemorySegment(VectorSpecies<Float> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static FloatVector`
  FloatVector.`fromMemorySegment(VectorSpecies<Float> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Float> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `static IntVector`
  IntVector.`fromMemorySegment(VectorSpecies<Integer> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static IntVector`
  IntVector.`fromMemorySegment(VectorSpecies<Integer> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Integer> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `static LongVector`
  LongVector.`fromMemorySegment(VectorSpecies<Long> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static LongVector`
  LongVector.`fromMemorySegment(VectorSpecies<Long> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Long> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `static ShortVector`
  ShortVector.`fromMemorySegment(VectorSpecies<Short> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment.
  `static ShortVector`
  ShortVector.`fromMemorySegment(VectorSpecies<Short> species, MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Short> m)`
  Loads a vector from a memory segmentPREVIEW starting at an offset into the memory segment and using a mask.
  `Vector<E>`
  VectorSpecies.`fromMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Loads a vector of this species from a memory segmentPREVIEW starting at an offset into the memory segment.
  `final void`
  ByteVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  ByteVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Byte> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `final void`
  DoubleVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  DoubleVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Double> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `final void`
  FloatVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  FloatVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Float> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `final void`
  IntVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  IntVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Integer> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `final void`
  LongVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  LongVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Long> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `final void`
  ShortVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `final void`
  ShortVector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<Short> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.
  `abstract void`
  Vector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order.
  `abstract void`
  Vector.`intoMemorySegment(MemorySegmentPREVIEW ms, long offset, ByteOrder bo, VectorMask<E> m)`
  Stores this vector into a memory segmentPREVIEW starting at an offset using explicit byte order and a mask.