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 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.default MemorySegmentSegmentAllocator.allocate(MemoryLayout layout) Allocate a memory segment with given layout.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfAddress layout, Addressable value) Allocate a memory segment with given layout and initialize it with given address value (expressed as anAddressableinstance).default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfByte layout, byte value) Allocate a memory segment with given layout and initialize it with given byte value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfChar layout, char value) Allocate a memory segment with given layout and initialize it with given char value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfDouble layout, double value) Allocate a memory segment with given layout and initialize it with given double value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfFloat layout, float value) Allocate a memory segment with given layout and initialize it with given float value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfInt layout, int value) Allocate a memory segment with given layout and initialize it with given int value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfLong layout, long value) Allocate a memory segment with given layout and initialize it with given long value.default MemorySegmentSegmentAllocator.allocate(ValueLayout.OfShort layout, short value) Allocate a memory segment with given layout and initialize it with given short value.default MemorySegmentSegmentAllocator.allocateArray(MemoryLayout elementLayout, long count) Allocate a memory segment with given element layout and size.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfByte elementLayout, byte[] array) Allocate a memory segment with given layout and initialize it with given byte array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfChar elementLayout, char[] array) Allocate a memory segment with given layout and initialize it with given char array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfDouble elementLayout, double[] array) Allocate a memory segment with given layout and initialize it with given double array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfFloat elementLayout, float[] array) Allocate a memory segment with given layout and initialize it with given float array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfInt elementLayout, int[] array) Allocate a memory segment with given layout and initialize it with given int array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfLong elementLayout, long[] array) Allocate a memory segment with given layout and initialize it with given long array.default MemorySegmentSegmentAllocator.allocateArray(ValueLayout.OfShort elementLayout, short[] array) Allocate a memory segment with given layout and initialize it with given short array.static MemorySegmentMemorySegment.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.static MemorySegmentMemorySegment.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.static MemorySegmentMemorySegment.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.default MemorySegmentSegmentAllocator.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.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.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.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.VaList.nextVarg(GroupLayout layout, SegmentAllocator allocator) Reads the next value as aMemorySegment, and advances this variable argument list's position.static MemorySegmentMemorySegment.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.static MemorySegmentMemorySegment.ofArray(byte[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated byte array.static MemorySegmentMemorySegment.ofArray(char[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated char array.static MemorySegmentMemorySegment.ofArray(double[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated double array.static MemorySegmentMemorySegment.ofArray(float[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated float array.static MemorySegmentMemorySegment.ofArray(int[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated int array.static MemorySegmentMemorySegment.ofArray(long[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated long array.static MemorySegmentMemorySegment.ofArray(short[] arr) Creates a new array memory segment that models the memory associated with a given heap-allocated short array.static MemorySegmentMemorySegment.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 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 TypeMethodDescriptionVaList.Builder.addVarg(GroupLayout layout, MemorySegment value) Writes aMemorySegmentvalue, 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 voidMemorySegment.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 voidMemorySegment.copy(MemorySegment srcSegment, long srcOffset, MemorySegment dstSegment, long dstOffset, long bytes) Performs a bulk copy from source segment to destination segment.static voidMemorySegment.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 voidMemorySegment.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.default MemorySegmentMemorySegment.copyFrom(MemorySegment src) Performs a bulk copy from given source segment to this segment.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.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 offset0(alignment constraints are ignored by this allocator), hence the name prefix allocator.longMemorySegment.segmentOffset(MemorySegment other) Returns the offset, in bytes, of the provided segment, relative to this segment.