Uses of Interface
java.lang.foreign.MemorySegment

  • Uses of MemorySegment in java.lang.foreign

    Fields in java.lang.foreign declared as MemorySegment
    Modifier and Type
    Field
    Description
    static final MemorySegment
    MemorySegment.NULL
    A zero-length native segment modelling the NULL address.
    Methods in java.lang.foreign that return MemorySegment
    Modifier and Type
    Method
    Description
    Arena.allocate(long byteSize, long byteAlignment)
    Returns a native memory segment with the given size (in bytes) and alignment constraint (in bytes).
    SegmentAllocator.allocate(long byteSize)
    Returns a new memory segment with the given byteSize.
    SegmentAllocator.allocate(long byteSize, long byteAlignment)
    Returns a new memory segment with the given byteSize and byteAlignment.
    SegmentAllocator.allocate(MemoryLayout layout)
    Returns a new memory segment with the given layout.
    SegmentAllocator.allocate(MemoryLayout elementLayout, long count)
    Returns a new memory segment with the given elementLayout and count.
    SegmentAllocator.allocateFrom(AddressLayout layout, MemorySegment value)
    Returns a new memory segment initialized with the address of the provided value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfByte layout, byte value)
    Returns a new memory segment initialized with the provided byte value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfByte elementLayout, byte... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E byte elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfChar layout, char value)
    Returns a new memory segment initialized with the provided char value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfChar elementLayout, char... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E char elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfDouble layout, double value)
    Returns a new memory segment initialized with the provided double value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfDouble elementLayout, double... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E double elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfFloat layout, float value)
    Returns a new memory segment initialized with the provided float value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfFloat elementLayout, float... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E float elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfInt layout, int value)
    Returns a new memory segment initialized with the provided int value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfInt elementLayout, int... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E int elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfLong layout, long value)
    Returns a new memory segment initialized with the provided long value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfLong elementLayout, long... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E long elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfShort layout, short value)
    Returns a new memory segment initialized with the provided short value as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(ValueLayout.OfShort elementLayout, short... elements)
    Returns a new memory segment with a byteSize() of E*layout.byteSize() initialized with the provided E short elements as specified by the provided layout (i.e. byte ordering, alignment and size).
    SegmentAllocator.allocateFrom(String str)
    Converts a Java string into a null-terminated C string using the UTF-8 charset, storing the result into a memory segment.
    SegmentAllocator.allocateFrom(String str, Charset charset)
    Converts a Java string into a null-terminated C string using the provided charset, and storing the result into a memory segment.
    MemorySegment.asReadOnly()
    Returns a read-only view of this segment.
    MemorySegment.asSlice(long offset)
    Returns a slice of this memory segment, at the given offset.
    MemorySegment.asSlice(long offset, long newSize)
    Returns a slice of this memory segment, at the given offset.
    MemorySegment.asSlice(long offset, long newSize, long byteAlignment)
    Returns a slice of this memory segment, at the given offset, with the provided alignment constraint.
    MemorySegment.asSlice(long offset, MemoryLayout layout)
    Returns a slice of this memory segment with the given layout, at the given offset.
    MemorySegment.copyFrom(MemorySegment src)
    Performs a bulk copy from given source segment to this segment.
    MemorySegment.fill(byte value)
    Fills the contents of this memory segment with the given value.
    MemorySegment.get(AddressLayout layout, long offset)
    Reads an address from this segment at the given offset, with the given layout.
    MemorySegment.getAtIndex(AddressLayout layout, long index)
    Reads an address from this segment at the given at the given index, scaled by the given layout size.
    MemorySegment.ofAddress(long address)
    Creates a zero-length native segment from the given address value.
    MemorySegment.ofArray(byte[] byteArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given byte array.
    MemorySegment.ofArray(char[] charArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given char array.
    MemorySegment.ofArray(double[] doubleArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given double array.
    MemorySegment.ofArray(float[] floatArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given float array.
    MemorySegment.ofArray(int[] intArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given int array.
    MemorySegment.ofArray(long[] longArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given long array.
    MemorySegment.ofArray(short[] shortArray)
    Creates a heap segment backed by the on-heap region of memory that holds the given short array.
    MemorySegment.ofBuffer(Buffer buffer)
    Creates a memory segment that is backed by the same region of memory that backs the given Buffer instance.
    MemorySegment.reinterpret(long newSize)
    Returns a new memory segment that has the same address and scope as this segment, but with the provided size.
    MemorySegment.reinterpret(long newSize, Arena arena, Consumer<MemorySegment> cleanup)
    Returns a new segment with the same address as this segment, but with the provided size and scope.
    MemorySegment.reinterpret(Arena arena, Consumer<MemorySegment> cleanup)
    Returns a new memory segment with the same address and size as this segment, but with the provided scope.
    Linker.upcallStub(MethodHandle target, FunctionDescriptor function, Arena arena, Linker.Option... options)
    Creates an upcall stub which can be passed to other foreign functions as a function pointer, associated with the given arena.
    Methods in java.lang.foreign that return types with arguments of type MemorySegment
    Modifier and Type
    Method
    Description
    MemorySegment.asOverlappingSlice(MemorySegment other)
    Returns a slice of this segment that is the overlap between this and the provided segment.
    MemorySegment.elements(MemoryLayout elementLayout)
    Returns a sequential Stream over disjoint slices (whose size matches that of the specified layout) in this segment.
    SymbolLookup.find(String name)
    Returns the address of the symbol with the given name.
    MemorySegment.spliterator(MemoryLayout elementLayout)
    Returns a spliterator for this memory segment.
    Methods in java.lang.foreign with parameters of type MemorySegment
    Modifier and Type
    Method
    Description
    SegmentAllocator.allocateFrom(AddressLayout layout, MemorySegment value)
    Returns a new memory segment initialized with the address of the provided value as specified by the provided layout (i.e. byte ordering, alignment and size).
    MemorySegment.asOverlappingSlice(MemorySegment other)
    Returns a slice of this segment that is the overlap between this and the provided segment.
    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 srcElementLayout, long srcOffset, MemorySegment dstSegment, ValueLayout dstElementLayout, long dstOffset, long elementCount)
    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 memory segment to a destination array.
    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 memory segment.
    MemorySegment.copyFrom(MemorySegment src)
    Performs a bulk copy from given source segment to this segment.
    Linker.downcallHandle(MemorySegment address, FunctionDescriptor function, Linker.Option... options)
    Creates a method handle which is used to call a foreign function with the given signature and address.
    default long
    MemorySegment.mismatch(MemorySegment other)
    Finds and returns the offset, in bytes, of the first mismatch between this segment and the given other segment.
    static long
    MemorySegment.mismatch(MemorySegment srcSegment, long srcFromOffset, long srcToOffset, MemorySegment dstSegment, long dstFromOffset, long dstToOffset)
    Finds and returns the relative offset, in bytes, of the first mismatch between the source and the destination segments.
    SegmentAllocator.prefixAllocator(MemorySegment segment)
    Returns a segment allocator which responds to allocation requests by recycling a single segment.
    default void
    MemorySegment.set(AddressLayout layout, long offset, MemorySegment value)
    Writes an address into this segment at the given offset, with the given layout.
    default void
    MemorySegment.setAtIndex(AddressLayout layout, long index, MemorySegment value)
    Writes an address into this segment at the given index, scaled by the given layout size.
    SegmentAllocator.slicingAllocator(MemorySegment segment)
    Returns a segment allocator which responds to allocation requests by returning consecutive slices obtained from the provided segment.
    Method parameters in java.lang.foreign with type arguments of type MemorySegment
    Modifier and Type
    Method
    Description
    MemorySegment.reinterpret(long newSize, Arena arena, Consumer<MemorySegment> cleanup)
    Returns a new segment with the same address as this segment, but with the provided size and scope.
    MemorySegment.reinterpret(Arena arena, Consumer<MemorySegment> cleanup)
    Returns a new memory segment with the same address and size as this segment, but with the provided scope.