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 MemorySegmentModifier and TypeMethodDescriptiondefault MemorySegmentSegmentAllocator.allocate(long bytesSize) Allocate a block of memory with given size, with default alignment (1-byte aligned).SegmentAllocator.allocate(long bytesSize, long bytesAlignment) Allocate a block of memory with given size and alignment constraint.default MemorySegmentSegmentAllocator.allocate(MemoryLayout layout) Allocate a block of memory with given layout.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, byte value) Allocate a block of memory with given layout and initialize it with given byte value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, char value) Allocate a block of memory with given layout and initialize it with given char value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, double value) Allocate a block of memory with given layout and initialize it with given double value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, float value) Allocate a block of memory with given layout and initialize it with given float value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, int value) Allocate a block of memory with given layout and initialize it with given int value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, long value) Allocate a block of memory with given layout and initialize it with given long value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, short value) Allocate a block of memory with given layout and initialize it with given short value.default MemorySegmentSegmentAllocator.allocate(ValueLayout layout, Addressable value) Allocate a block of memory with given layout and initialize it with given address value (expressed as anAddressableinstance).default MemorySegmentSegmentAllocator.allocateArray(MemoryLayout elementLayout, long count) Allocate a block of memory corresponding to an array with given element layout and size.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, byte[] array) Allocate a block of memory with given layout and initialize it with given byte array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, char[] array) Allocate a block of memory with given layout and initialize it with given char array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, double[] array) Allocate a block of memory with given layout and initialize it with given double array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, float[] array) Allocate a block of memory with given layout and initialize it with given float array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, int[] array) Allocate a block of memory with given layout and initialize it with given int array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, long[] array) Allocate a block of memory with given layout and initialize it with given long array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, short[] array) Allocate a block of memory with given layout and initialize it with given short array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout elementLayout, Addressable[] array) Allocate a block of memory with given layout and initialize it with given address array.static MemorySegmentMemorySegment.allocateNative(long bytesSize, long alignmentBytes, ResourceScope scope) Creates a new confined 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.static MemorySegmentMemorySegment.allocateNative(long bytesSize, ResourceScope scope) Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given size (in bytes) and resource scope.static MemorySegmentMemorySegment.allocateNative(MemoryLayout layout, ResourceScope scope) Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given layout and resource scope.MemorySegment.asReadOnly()Obtains a read-only view of this segment.MemoryAddress.asSegment(long bytesSize, Runnable cleanupAction, ResourceScope scope) Returns a new native memory segment with given size and resource scope (replacing the scope already associated with this address), and whose base address is this address.MemoryAddress.asSegment(long bytesSize, ResourceScope scope) Returns a new native memory segment with given size and resource scope (replacing the scope already associated with this address), and whose base address is this address.default MemorySegmentMemorySegment.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.default MemorySegmentMemorySegment.asSlice(MemoryAddress newBase) Obtains a new memory segment view whose base address is the given address, and whose new size is computed by subtracting the address offset relative to this segment (seeMemoryAddress.segmentOffset(MemorySegment)) from this segment size.default MemorySegmentMemorySegment.asSlice(MemoryAddress newBase, long newSize) Obtains a new memory segment view whose base address is the given address, and whose new size is specified by the given argument.MemorySegment.fill(byte value) Fills a value into this memory segment.static MemorySegmentMemorySegment.globalNativeSegment()Returns a native memory segment whose base address isMemoryAddress.NULLand whose size isLong.MAX_VALUE.static MemorySegmentMemorySegment.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.static MemorySegmentMemorySegment.ofArray(byte[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated byte array.static MemorySegmentMemorySegment.ofArray(char[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated char array.static MemorySegmentMemorySegment.ofArray(double[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated double array.static MemorySegmentMemorySegment.ofArray(float[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated float array.static MemorySegmentMemorySegment.ofArray(int[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated int array.static MemorySegmentMemorySegment.ofArray(long[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated long array.static MemorySegmentMemorySegment.ofArray(short[] arr) Creates a new confined array memory segment that models the memory associated with a given heap-allocated short array.static MemorySegmentMemorySegment.ofByteBuffer(ByteBuffer bb) Creates a new confined buffer memory segment that models the memory associated with the given byte buffer.static MemorySegmentCLinker.toCString(String str, ResourceScope scope) Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a native memory segment associated with the provided resource scope.static MemorySegmentCLinker.toCString(String str, SegmentAllocator allocator) Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a native memory segment allocated using the provided allocator.CLinker.VaList.vargAsSegment(MemoryLayout layout, ResourceScope scope) Reads the next value as aMemorySegment, and advances this va list's position.CLinker.VaList.vargAsSegment(MemoryLayout layout, SegmentAllocator allocator) Reads the next value as aMemorySegment, and advances this va list's position.Methods in jdk.incubator.foreign that return types with arguments of type MemorySegmentModifier and TypeMethodDescriptionMemorySegment.elements(MemoryLayout elementLayout) Returns a sequentialStreamover 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 MemorySegmentModifier and TypeMethodDescriptionvoidMemorySegment.copyFrom(MemorySegment src) Performs a bulk copy from given source segment to this segment.static MemoryAddressMemoryAccess.getAddress(MemorySegment segment) Reads a memory address from given segment, with byte order set toByteOrder.nativeOrder().static MemoryAddressMemoryAccess.getAddressAtIndex(MemorySegment segment, long index) Reads a memory address from given segment and element index, with byte order set toByteOrder.nativeOrder().static MemoryAddressMemoryAccess.getAddressAtOffset(MemorySegment segment, long offset) Reads a memory address from given segment and offset, with byte order set toByteOrder.nativeOrder().static byteMemoryAccess.getByte(MemorySegment segment) Reads a byte from given segment.static byteMemoryAccess.getByteAtOffset(MemorySegment segment, long offset) Reads a byte from given segment and offset.static charMemoryAccess.getChar(MemorySegment segment) Reads a char from given segment, with byte order set toByteOrder.nativeOrder().static charMemoryAccess.getChar(MemorySegment segment, ByteOrder order) Reads a char from given segment, with given byte order.static charMemoryAccess.getCharAtIndex(MemorySegment segment, long index) Reads a char from given segment and element index, with byte order set toByteOrder.nativeOrder().static charMemoryAccess.getCharAtIndex(MemorySegment segment, long index, ByteOrder order) Reads a char from given segment and element index, with given byte order.static charMemoryAccess.getCharAtOffset(MemorySegment segment, long offset) Reads a char from given segment and offset, with byte order set toByteOrder.nativeOrder().static charMemoryAccess.getCharAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads a char from given segment and offset with given byte order.static doubleMemoryAccess.getDouble(MemorySegment segment) Reads a double from given segment, with byte order set toByteOrder.nativeOrder().static doubleMemoryAccess.getDouble(MemorySegment segment, ByteOrder order) Reads a double from given segment, with given byte order.static doubleMemoryAccess.getDoubleAtIndex(MemorySegment segment, long index) Reads a double from given segment and element index, with byte order set toByteOrder.nativeOrder().static doubleMemoryAccess.getDoubleAtIndex(MemorySegment segment, long index, ByteOrder order) Reads a double from given segment and element index, with given byte order.static doubleMemoryAccess.getDoubleAtOffset(MemorySegment segment, long offset) Reads a double from given segment and offset, with byte order set toByteOrder.nativeOrder().static doubleMemoryAccess.getDoubleAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads a double from given segment and offset with given byte order.static floatMemoryAccess.getFloat(MemorySegment segment) Reads a float from given segment, with byte order set toByteOrder.nativeOrder().static floatMemoryAccess.getFloat(MemorySegment segment, ByteOrder order) Reads a float from given segment, with given byte order.static floatMemoryAccess.getFloatAtIndex(MemorySegment segment, long index) Reads a float from given segment and element index, with byte order set toByteOrder.nativeOrder().static floatMemoryAccess.getFloatAtIndex(MemorySegment segment, long index, ByteOrder order) Reads a float from given segment and element index, with given byte order.static floatMemoryAccess.getFloatAtOffset(MemorySegment segment, long offset) Reads a float from given segment and offset, with byte order set toByteOrder.nativeOrder().static floatMemoryAccess.getFloatAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads a float from given segment and offset with given byte order.static intMemoryAccess.getInt(MemorySegment segment) Reads an int from given segment, with byte order set toByteOrder.nativeOrder().static intMemoryAccess.getInt(MemorySegment segment, ByteOrder order) Reads an int from given segment, with given byte order.static intMemoryAccess.getIntAtIndex(MemorySegment segment, long index) Reads an int from given segment and element index, with byte order set toByteOrder.nativeOrder().static intMemoryAccess.getIntAtIndex(MemorySegment segment, long index, ByteOrder order) Reads an int from given segment and element index, with given byte order.static intMemoryAccess.getIntAtOffset(MemorySegment segment, long offset) Reads an int from given segment and offset, with byte order set toByteOrder.nativeOrder().static intMemoryAccess.getIntAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads an int from given segment and offset with given byte order.static longMemoryAccess.getLong(MemorySegment segment) Reads a long from given segment, with byte order set toByteOrder.nativeOrder().static longMemoryAccess.getLong(MemorySegment segment, ByteOrder order) Reads a long from given segment, with given byte order.static longMemoryAccess.getLongAtIndex(MemorySegment segment, long index) Reads a long from given segment and element index, with byte order set toByteOrder.nativeOrder().static longMemoryAccess.getLongAtIndex(MemorySegment segment, long index, ByteOrder order) Reads a long from given segment and element index, with given byte order.static longMemoryAccess.getLongAtOffset(MemorySegment segment, long offset) Reads a long from given segment and offset, with byte order set toByteOrder.nativeOrder().static longMemoryAccess.getLongAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads a long from given segment and offset with given byte order.static shortMemoryAccess.getShort(MemorySegment segment) Reads a short from given segment, with byte order set toByteOrder.nativeOrder().static shortMemoryAccess.getShort(MemorySegment segment, ByteOrder order) Reads a short from given segment, with given byte order.static shortMemoryAccess.getShortAtIndex(MemorySegment segment, long index) Reads a short from given segment and element index, with byte order set toByteOrder.nativeOrder().static shortMemoryAccess.getShortAtIndex(MemorySegment segment, long index, ByteOrder order) Reads a short from given segment and element index, with given byte order.static shortMemoryAccess.getShortAtOffset(MemorySegment segment, long offset) Reads a short from given segment and offset, with byte order set toByteOrder.nativeOrder().static shortMemoryAccess.getShortAtOffset(MemorySegment segment, long offset, ByteOrder order) Reads a short from given segment and offset with given byte order.longMemorySegment.mismatch(MemorySegment other) Finds and returns the offset, in bytes, of the first mismatch between this segment and a given other segment.static SegmentAllocatorSegmentAllocator.ofSegment(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 offset0(alignment constraints are ignored by this allocator).longMemoryAddress.segmentOffset(MemorySegment segment) Returns the offset of this memory address into the given segment.static voidMemoryAccess.setAddress(MemorySegment segment, Addressable value) Writes a memory address at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setAddressAtIndex(MemorySegment segment, long index, Addressable value) Writes a memory address at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setAddressAtOffset(MemorySegment segment, long offset, Addressable value) Writes a memory address at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setByte(MemorySegment segment, byte value) Writes a byte at given segment.static voidMemoryAccess.setByteAtOffset(MemorySegment segment, long offset, byte value) Writes a byte at given segment and offset.static voidMemoryAccess.setChar(MemorySegment segment, char value) Writes a char at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setChar(MemorySegment segment, ByteOrder order, char value) Writes a char at given segment, with given byte order.static voidMemoryAccess.setCharAtIndex(MemorySegment segment, long index, char value) Writes a char at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setCharAtIndex(MemorySegment segment, long index, ByteOrder order, char value) Writes a char at given segment and element index, with given byte order.static voidMemoryAccess.setCharAtOffset(MemorySegment segment, long offset, char value) Writes a char at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setCharAtOffset(MemorySegment segment, long offset, ByteOrder order, char value) Writes a char at given segment and offset with given byte order.static voidMemoryAccess.setDouble(MemorySegment segment, double value) Writes a double at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setDouble(MemorySegment segment, ByteOrder order, double value) Writes a double at given segment, with given byte order.static voidMemoryAccess.setDoubleAtIndex(MemorySegment segment, long index, double value) Writes a double at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setDoubleAtIndex(MemorySegment segment, long index, ByteOrder order, double value) Writes a double at given segment and element index, with given byte order.static voidMemoryAccess.setDoubleAtOffset(MemorySegment segment, long offset, double value) Writes a double at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setDoubleAtOffset(MemorySegment segment, long offset, ByteOrder order, double value) Writes a double at given segment and offset with given byte order.static voidMemoryAccess.setFloat(MemorySegment segment, float value) Writes a float at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setFloat(MemorySegment segment, ByteOrder order, float value) Writes a float at given segment, with given byte order.static voidMemoryAccess.setFloatAtIndex(MemorySegment segment, long index, float value) Writes a float at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setFloatAtIndex(MemorySegment segment, long index, ByteOrder order, float value) Writes a float at given segment and element index, with given byte order.static voidMemoryAccess.setFloatAtOffset(MemorySegment segment, long offset, float value) Writes a float at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setFloatAtOffset(MemorySegment segment, long offset, ByteOrder order, float value) Writes a float at given segment and offset with given byte order.static voidMemoryAccess.setInt(MemorySegment segment, int value) Writes an int at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setInt(MemorySegment segment, ByteOrder order, int value) Writes an int at given segment, with given byte order.static voidMemoryAccess.setIntAtIndex(MemorySegment segment, long index, int value) Writes an int at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setIntAtIndex(MemorySegment segment, long index, ByteOrder order, int value) Writes an int at given segment and element index, with given byte order.static voidMemoryAccess.setIntAtOffset(MemorySegment segment, long offset, int value) Writes an int at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setIntAtOffset(MemorySegment segment, long offset, ByteOrder order, int value) Writes an int at given segment and offset with given byte order.static voidMemoryAccess.setLong(MemorySegment segment, long value) Writes a long at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setLong(MemorySegment segment, ByteOrder order, long value) Writes a long at given segment, with given byte order.static voidMemoryAccess.setLongAtIndex(MemorySegment segment, long index, long value) Writes a long at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setLongAtIndex(MemorySegment segment, long index, ByteOrder order, long value) Writes a long at given segment and element index, with given byte order.static voidMemoryAccess.setLongAtOffset(MemorySegment segment, long offset, long value) Writes a long at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setLongAtOffset(MemorySegment segment, long offset, ByteOrder order, long value) Writes a long at given segment and offset with given byte order.static voidMemoryAccess.setShort(MemorySegment segment, short value) Writes a short at given segment, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setShort(MemorySegment segment, ByteOrder order, short value) Writes a short at given segment, with given byte order.static voidMemoryAccess.setShortAtIndex(MemorySegment segment, long index, short value) Writes a short at given segment and element index, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setShortAtIndex(MemorySegment segment, long index, ByteOrder order, short value) Writes a short at given segment and element index, with given byte order.static voidMemoryAccess.setShortAtOffset(MemorySegment segment, long offset, short value) Writes a short at given segment and offset, with byte order set toByteOrder.nativeOrder().static voidMemoryAccess.setShortAtOffset(MemorySegment segment, long offset, ByteOrder order, short value) Writes a short at given segment and offset with given byte order.static StringCLinker.toJavaString(MemorySegment addr) Converts a UTF-8 encoded, null-terminated C string stored at given address into a Java string.CLinker.VaList.Builder.vargFromSegment(GroupLayout layout, MemorySegment value) Adds a native value represented as aMemorySegmentto the Cva_listbeing constructed.