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 MemorySegmentNativeScope.allocate(long bytesSize)Allocate a block of memory in this native scope with given size.NativeScope.allocate(long bytesSize, long bytesAlignment)Allocate a block of memory in this native scope with given size and alignment constraint.default MemorySegmentNativeScope.allocate(MemoryLayout layout)Allocate a block of memory in this native scope with given layout.default MemorySegmentNativeScope.allocate(ValueLayout layout, byte value)Allocate a block of memory in this native scope with given layout and initialize it with given byte value.default MemorySegmentNativeScope.allocate(ValueLayout layout, char value)Allocate a block of memory in this native scope with given layout and initialize it with given char value.default MemorySegmentNativeScope.allocate(ValueLayout layout, double value)Allocate a block of memory in this native scope with given layout and initialize it with given double value.default MemorySegmentNativeScope.allocate(ValueLayout layout, float value)Allocate a block of memory in this native scope with given layout and initialize it with given float value.default MemorySegmentNativeScope.allocate(ValueLayout layout, int value)Allocate a block of memory in this native scope with given layout and initialize it with given int value.default MemorySegmentNativeScope.allocate(ValueLayout layout, long value)Allocate a block of memory in this native scope with given layout and initialize it with given long value.default MemorySegmentNativeScope.allocate(ValueLayout layout, short value)Allocate a block of memory in this native scope with given layout and initialize it with given short value.default MemorySegmentNativeScope.allocate(ValueLayout layout, Addressable value)Allocate a block of memory in this native scope with given layout and initialize it with given address value (expressed as anAddressableinstance).default MemorySegmentNativeScope.allocateArray(MemoryLayout elementLayout, long count)Allocate a block of memory corresponding to an array with given element layout and size.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, byte[] array)Allocate a block of memory in this native scope with given layout and initialize it with given byte array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, char[] array)Allocate a block of memory in this native scope with given layout and initialize it with given char array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, double[] array)Allocate a block of memory in this native scope with given layout and initialize it with given double array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, float[] array)Allocate a block of memory in this native scope with given layout and initialize it with given float array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, int[] array)Allocate a block of memory in this native scope with given layout and initialize it with given int array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, long[] array)Allocate a block of memory in this native scope with given layout and initialize it with given long array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, short[] array)Allocate a block of memory in this native scope with given layout and initialize it with given short array.default MemorySegmentNativeScope.allocateArray(ValueLayout elementLayout, Addressable[] array)Allocate a block of memory in this native scope with given layout and initialize it with given address array.static MemorySegmentMemorySegment.allocateNative(long bytesSize)Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given size (in bytes).static MemorySegmentMemorySegment.allocateNative(long bytesSize, long alignmentBytes)Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given size and alignment constraint (in bytes).static MemorySegmentMemorySegment.allocateNative(MemoryLayout layout)Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given layout.default MemorySegmentMemoryAddress.asSegmentRestricted(long bytesSize)Returns a new confined native memory segment with given size, and whose base address is this address; the returned segment has its own temporal bounds, and can therefore be closed.MemoryAddress.asSegmentRestricted(long bytesSize, Runnable cleanupAction, Object attachment)Returns a new confined native memory segment with given size, and whose base address is this address; the returned segment has its own temporal bounds, and can therefore be closed.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.Obtains a new confined memory segment backed by the same underlying memory region as this segment.MemorySegment.handoff(NativeScope nativeScope)Obtains a new confined memory segment backed by the same underlying memory region as this segment, but whose temporal bounds are controlled by the providedNativeScopeinstance.static MemorySegmentMemorySegment.mapFile(Path path, long bytesOffset, long bytesSize, FileChannel.MapMode mapMode)Creates a new confined 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 MemorySegmentMemorySegment.ofNativeRestricted()Returns a shared native memory segment whose base address isMemoryAddress.NULLand whose size isLong.MAX_VALUE.MemorySegment.registerCleaner(Cleaner cleaner)Register this memory segment instance against aCleanerobject, by returning a new memory segment backed by the same underlying memory region as this segment.MemorySegment.share()Obtains a new shared memory segment backed by the same underlying memory region as this segment.static MemorySegmentConverts a Java string into a null-terminated C string, using the platform's default charset, storing the result into a new native memory segment.static MemorySegmentConverts a Java string into a null-terminated C string, using the givencharset, storing the result into a new native memory segment.static MemorySegmentCLinker.toCString(String str, Charset charset, NativeScope scope)Converts a Java string into a null-terminated C string, using the givencharset, storing the result into a new native memory segment native memory segment allocated using the provided scope.static MemorySegmentCLinker.toCString(String str, NativeScope scope)Converts a Java string into a null-terminated C string, using the platform's default charset, storing the result into a native memory segment allocated using the provided scope.CLinker.upcallStub(MethodHandle target, FunctionDescriptor function)Allocates a native segment whose base address (seeaddress()) can be passed to other foreign functions (as a function pointer); calling such a function pointer from native code will result in the execution of the provided method handle.CLinker.VaList.vargAsSegment(MemoryLayout layout)Reads the next value as aMemorySegment, and advances this va list's position.CLinker.VaList.vargAsSegment(MemoryLayout layout, NativeScope scope)Reads the next value as aMemorySegment, and advances this va list's position.MemorySegment.withAccessModes(int accessModes)Obtains a segment view with specific access modes.Methods in jdk.incubator.foreign that return types with arguments of type MemorySegmentModifier and TypeMethodDescriptionMemorySegment.spliterator(SequenceLayout layout)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 voidMappedMemorySegments.force(MemorySegment segment)Forces any changes made to the contents of the given segment to be written to the storage device described by the mapped segment's file descriptor.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.static booleanMappedMemorySegments.isLoaded(MemorySegment segment)Tells whether or not the contents of the given segment is resident in physical memory.static voidMappedMemorySegments.load(MemorySegment segment)Loads the contents of the given segment into physical memory.longMemorySegment.mismatch(MemorySegment other)Finds and returns the offset, in bytes, of the first mismatch between this segment and a given other segment.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 null-terminated C string stored at given address into a Java string, using the platform's default charset.static StringCLinker.toJavaString(MemorySegment addr, Charset charset)Converts a null-terminated C string stored at given address into a Java string, using the givencharset.static voidMappedMemorySegments.unload(MemorySegment segment)Unloads the contents of the given segment from physical memory.CLinker.VaList.Builder.vargFromSegment(GroupLayout layout, MemorySegment value)Adds a native value represented as aMemorySegmentto the Cva_listbeing constructed.