Uses of Interface
jdk.incubator.foreign.MemorySegment

Packages that use MemorySegment
Package
Description
Classes to support low-level and efficient foreign memory/function access, directly from Java.
  • Uses of MemorySegment in jdk.incubator.foreign

    Methods in jdk.incubator.foreign that return MemorySegment
    Modifier and Type
    Method
    Description
    SegmentAllocator.allocate(long bytesSize)
    Allocate a memory segment with given size and default alignment constraints (1-byte aligned).
    SegmentAllocator.allocate(long bytesSize, long bytesAlignment)
    Allocate a memory segment with given size and alignment constraints.
    SegmentAllocator.allocate(MemoryLayout layout)
    Allocate a memory segment with given layout.
    SegmentAllocator.allocate(ValueLayout.OfAddress layout, Addressable value)
    Allocate a memory segment with given layout and initialize it with given address value (expressed as an Addressable instance).
    SegmentAllocator.allocate(ValueLayout.OfByte layout, byte value)
    Allocate a memory segment with given layout and initialize it with given byte value.
    SegmentAllocator.allocate(ValueLayout.OfChar layout, char value)
    Allocate a memory segment with given layout and initialize it with given char value.
    SegmentAllocator.allocate(ValueLayout.OfDouble layout, double value)
    Allocate a memory segment with given layout and initialize it with given double value.
    SegmentAllocator.allocate(ValueLayout.OfFloat layout, float value)
    Allocate a memory segment with given layout and initialize it with given float value.
    SegmentAllocator.allocate(ValueLayout.OfInt layout, int value)
    Allocate a memory segment with given layout and initialize it with given int value.
    SegmentAllocator.allocate(ValueLayout.OfLong layout, long value)
    Allocate a memory segment with given layout and initialize it with given long value.
    SegmentAllocator.allocate(ValueLayout.OfShort layout, short value)
    Allocate a memory segment with given layout and initialize it with given short value.
    SegmentAllocator.allocateArray(MemoryLayout elementLayout, long count)
    Allocate a memory segment with given element layout and size.
    SegmentAllocator.allocateArray(ValueLayout.OfByte elementLayout, byte[] array)
    Allocate a memory segment with given layout and initialize it with given byte array.
    SegmentAllocator.allocateArray(ValueLayout.OfChar elementLayout, char[] array)
    Allocate a memory segment with given layout and initialize it with given char array.
    SegmentAllocator.allocateArray(ValueLayout.OfDouble elementLayout, double[] array)
    Allocate a memory segment with given layout and initialize it with given double array.
    SegmentAllocator.allocateArray(ValueLayout.OfFloat elementLayout, float[] array)
    Allocate a memory segment with given layout and initialize it with given float array.
    SegmentAllocator.allocateArray(ValueLayout.OfInt elementLayout, int[] array)
    Allocate a memory segment with given layout and initialize it with given int array.
    SegmentAllocator.allocateArray(ValueLayout.OfLong elementLayout, long[] array)
    Allocate a memory segment with given layout and initialize it with given long array.
    SegmentAllocator.allocateArray(ValueLayout.OfShort elementLayout, short[] array)
    Allocate a memory segment with given layout and initialize it with given short array.
    MemorySegment.allocateNative(long bytesSize, long alignmentBytes, ResourceScope scope)
    Creates a new native memory segment that models a newly allocated block of off-heap memory with given size (in bytes), alignment constraint (in bytes) and resource scope.
    MemorySegment.allocateNative(long bytesSize, ResourceScope scope)
    Creates a new native memory segment that models a newly allocated block of off-heap memory with given size (in bytes) and resource scope.
    MemorySegment.allocateNative(MemoryLayout layout, ResourceScope scope)
    Creates a new native memory segment that models a newly allocated block of off-heap memory with given layout and resource scope.
    SegmentAllocator.allocateUtf8String(String str)
    Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a memory segment.
    MemorySegment.asOverlappingSlice(MemorySegment other)
    Returns a slice of this segment that is the overlap between this and the provided segment.
    MemorySegment.asReadOnly()
    Obtains a read-only view of this segment.
    MemorySegment.asSlice(long offset)
    Obtains a new memory segment view whose base address is the same as the base address of this segment plus a given offset, and whose new size is computed by subtracting the specified offset from this segment size.
    MemorySegment.asSlice(long offset, long newSize)
    Obtains a new memory segment view whose base address is the same as the base address of this segment plus a given offset, and whose new size is specified by the given argument.
    MemorySegment.copyFrom(MemorySegment src)
    Performs a bulk copy from given source segment to this segment.
    MemorySegment.fill(byte value)
    Fills a value into this memory segment.
    MemorySegment.mapFile(Path path, long bytesOffset, long bytesSize, FileChannel.MapMode mapMode, ResourceScope scope)
    Creates a new mapped memory segment that models a memory-mapped region of a file from a given path.
    VaList.nextVarg(GroupLayout layout, SegmentAllocator allocator)
    Reads the next value as a MemorySegment, and advances this variable argument list's position.
    MemorySegment.ofAddress(MemoryAddress address, long bytesSize, ResourceScope scope)
    Creates a new native memory segment with given size and resource scope, and whose base address is the given address.
    MemorySegment.ofArray(byte[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated byte array.
    MemorySegment.ofArray(char[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated char array.
    MemorySegment.ofArray(double[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated double array.
    MemorySegment.ofArray(float[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated float array.
    MemorySegment.ofArray(int[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated int array.
    MemorySegment.ofArray(long[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated long array.
    MemorySegment.ofArray(short[] arr)
    Creates a new array memory segment that models the memory associated with a given heap-allocated short array.
    MemorySegment.ofByteBuffer(ByteBuffer bb)
    Creates a new buffer memory segment that models the memory associated with the given byte buffer.
    Methods in jdk.incubator.foreign that return types with arguments of type MemorySegment
    Modifier and Type
    Method
    Description
    MemorySegment.elements(MemoryLayout elementLayout)
    Returns a sequential Stream over disjoint slices (whose size matches that of the specified layout) in this segment.
    MemorySegment.spliterator(MemoryLayout elementLayout)
    Returns a spliterator for this memory segment.
    Methods in jdk.incubator.foreign with parameters of type MemorySegment
    Modifier and Type
    Method
    Description
    VaList.Builder.addVarg(GroupLayout layout, MemorySegment value)
    Writes a MemorySegment value, with given layout, to the variable argument list being constructed.
    MemorySegment.asOverlappingSlice(MemorySegment other)
    Returns a slice of this segment that is the overlap between this and the provided segment.
    static void
    MemorySegment.copy(Object srcArray, int srcIndex, MemorySegment dstSegment, ValueLayout dstLayout, long dstOffset, int elementCount)
    Copies a number of elements from a source array to a destination segment, starting at a given array index, and a given segment offset (expressed in bytes), using the given destination element layout.
    static void
    MemorySegment.copy(MemorySegment srcSegment, long srcOffset, MemorySegment dstSegment, long dstOffset, long bytes)
    Performs a bulk copy from source segment to destination segment.
    static void
    MemorySegment.copy(MemorySegment srcSegment, ValueLayout srcLayout, long srcOffset, Object dstArray, int dstIndex, int elementCount)
    Copies a number of elements from a source segment to a destination array, starting at a given segment offset (expressed in bytes), and a given array index, using the given source element layout.
    static void
    MemorySegment.copy(MemorySegment srcSegment, ValueLayout srcElementLayout, long srcOffset, MemorySegment dstSegment, ValueLayout dstElementLayout, long dstOffset, long elementCount)
    Performs a bulk copy from source segment to destination segment.
    MemorySegment.copyFrom(MemorySegment src)
    Performs a bulk copy from given source segment to this segment.
    long
    MemorySegment.mismatch(MemorySegment other)
    Finds and returns the offset, in bytes, of the first mismatch between this segment and a given other segment.
    SegmentAllocator.prefixAllocator(MemorySegment segment)
    Returns a segment allocator which responds to allocation requests by recycling a single segment; that is, each new allocation request will return a new slice starting at the segment offset 0 (alignment constraints are ignored by this allocator), hence the name prefix allocator.
    long
    MemorySegment.segmentOffset(MemorySegment other)
    Returns the offset, in bytes, of the provided segment, relative to this segment.