Uses of Interface
java.lang.foreign.MemorySegment
Packages that use MemorySegment
Package
Description
Provides low-level access to memory and functions outside the Java runtime.
Defines channels, which represent connections to entities that are capable of
performing I/O operations, such as files and sockets; defines selectors, for
multiplexed, non-blocking I/O operations.
Incubating Feature. Will be removed in a future release.
-
Uses of MemorySegment in java.lang.foreign
Fields in java.lang.foreign declared as MemorySegmentModifier and TypeFieldDescriptionstatic final MemorySegmentMemorySegment.NULLA zero-length native segment modelling theNULLaddress.Methods in java.lang.foreign that return MemorySegmentModifier and TypeMethodDescriptionArena.allocate(long byteSize, long byteAlignment) Returns a native memory segment with the given size (in bytes) and alignment constraint (in bytes).default MemorySegmentSegmentAllocator.allocate(long byteSize) Returns a new memory segment with the givenbyteSize.SegmentAllocator.allocate(long byteSize, long byteAlignment) Returns a new memory segment with the givenbyteSizeandbyteAlignment.default MemorySegmentSegmentAllocator.allocate(MemoryLayout layout) Returns a new memory segment with the given layout.default MemorySegmentSegmentAllocator.allocate(MemoryLayout elementLayout, long count) Returns a new memory segment with the givenelementLayoutandcount.default MemorySegmentSegmentAllocator.allocateFrom(AddressLayout layout, MemorySegment value) Returns a new memory segment initialized with the address of the provided memory segment.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfByte layout, byte value) Returns a new memory segment initialized with the provided byte value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfByte elementLayout, byte... elements) Returns a new memory segment initialized with the elements in the provided byte array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfChar layout, char value) Returns a new memory segment initialized with the provided char value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfChar elementLayout, char... elements) Returns a new memory segment initialized with the elements in the provided char array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfDouble layout, double value) Returns a new memory segment initialized with the provided double value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfDouble elementLayout, double... elements) Returns a new memory segment initialized with the elements in the provided double array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfFloat layout, float value) Returns a new memory segment initialized with the provided float value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfFloat elementLayout, float... elements) Returns a new memory segment initialized with the elements in the provided float array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfInt layout, int value) Returns a new memory segment initialized with the provided int value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfInt elementLayout, int... elements) Returns a new memory segment initialized with the elements in the provided int array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfLong layout, long value) Returns a new memory segment initialized with the provided long value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfLong elementLayout, long... elements) Returns a new memory segment initialized with the elements in the provided long array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfShort layout, short value) Returns a new memory segment initialized with the provided short value.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout.OfShort elementLayout, short... elements) Returns a new memory segment initialized with the elements in the provided short array.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout elementLayout, MemorySegment source, ValueLayout sourceElementLayout, long sourceOffset, long elementCount) Returns a new memory segment initialized with the contents of the provided segment.default MemorySegmentSegmentAllocator.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.default MemorySegmentSegmentAllocator.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 the given source segment to this segment.MemorySegment.fill(byte value) Fills the contents of this memory segment with the given value.default MemorySegmentSymbolLookup.findOrThrow(String name) Returns the address of the symbol with the given name or throws an exception.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.static MemorySegmentMemorySegment.ofAddress(long address) Creates a zero-length native segment from the given address value.static MemorySegmentMemorySegment.ofArray(byte[] byteArray) Creates a heap segment backed by the on-heap region of memory that holds the given byte array.static MemorySegmentMemorySegment.ofArray(char[] charArray) Creates a heap segment backed by the on-heap region of memory that holds the given char array.static MemorySegmentMemorySegment.ofArray(double[] doubleArray) Creates a heap segment backed by the on-heap region of memory that holds the given double array.static MemorySegmentMemorySegment.ofArray(float[] floatArray) Creates a heap segment backed by the on-heap region of memory that holds the given float array.static MemorySegmentMemorySegment.ofArray(int[] intArray) Creates a heap segment backed by the on-heap region of memory that holds the given int array.static MemorySegmentMemorySegment.ofArray(long[] longArray) Creates a heap segment backed by the on-heap region of memory that holds the given long array.static MemorySegmentMemorySegment.ofArray(short[] shortArray) Creates a heap segment backed by the on-heap region of memory that holds the given short array.static MemorySegmentCreates a memory segment that is backed by the same region of memory that backs the givenBufferinstance.MemorySegment.reinterpret(long newSize) Restricted.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) Restricted.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) Restricted.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) Restricted.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 MemorySegmentModifier and TypeMethodDescriptionMemorySegment.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 sequentialStreamover disjoint slices (whose size matches that of the specified layout) in this segment.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 MemorySegmentModifier and TypeMethodDescriptiondefault MemorySegmentSegmentAllocator.allocateFrom(AddressLayout layout, MemorySegment value) Returns a new memory segment initialized with the address of the provided memory segment.default MemorySegmentSegmentAllocator.allocateFrom(ValueLayout elementLayout, MemorySegment source, ValueLayout sourceElementLayout, long sourceOffset, long elementCount) Returns a new memory segment initialized with the contents of the provided segment.MemorySegment.asOverlappingSlice(MemorySegment other) Returns a slice of this segment that is the overlap between this and the provided segment.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 srcElementLayout, long srcOffset, MemorySegment dstSegment, ValueLayout dstElementLayout, long dstOffset, long elementCount) 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 memory segment to a destination array.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 memory segment.MemorySegment.copyFrom(MemorySegment src) Performs a bulk copy from the given source segment to this segment.Linker.downcallHandle(MemorySegment address, FunctionDescriptor function, Linker.Option... options) Restricted.Creates a method handle that is used to call a foreign function with the given signature and address.longMemorySegment.mismatch(MemorySegment other) Finds and returns the offset, in bytes, of the first mismatch between this segment and the given other segment.static longMemorySegment.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.static SegmentAllocatorSegmentAllocator.prefixAllocator(MemorySegment segment) Returns a segment allocator that responds to allocation requests by recycling a single segment.voidMemorySegment.set(AddressLayout layout, long offset, MemorySegment value) Writes an address into this segment at the given offset, with the given layout.voidMemorySegment.setAtIndex(AddressLayout layout, long index, MemorySegment value) Writes an address into this segment at the given index, scaled by the given layout size.static SegmentAllocatorSegmentAllocator.slicingAllocator(MemorySegment segment) Returns a segment allocator that responds to allocation requests by returning consecutive slices obtained from the provided segment.Method parameters in java.lang.foreign with type arguments of type MemorySegmentModifier and TypeMethodDescriptionMemorySegment.reinterpret(long newSize, Arena arena, Consumer<MemorySegment> cleanup) Restricted.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) Restricted.Returns a new memory segment with the same address and size as this segment, but with the provided scope. -
Uses of MemorySegment in java.nio.channels
Methods in java.nio.channels that return MemorySegmentModifier and TypeMethodDescriptionFileChannel.map(FileChannel.MapMode mode, long offset, long size, Arena arena) Maps a region of this channel's file into a new mapped memory segment, with the given offset, size and arena. -
Uses of MemorySegment in jdk.incubator.vector
Methods in jdk.incubator.vector with parameters of type MemorySegmentModifier and TypeMethodDescriptionstatic ByteVectorByteVector.fromMemorySegment(VectorSpecies<Byte> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static ByteVectorByteVector.fromMemorySegment(VectorSpecies<Byte> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Byte> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.static DoubleVectorDoubleVector.fromMemorySegment(VectorSpecies<Double> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static DoubleVectorDoubleVector.fromMemorySegment(VectorSpecies<Double> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Double> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.static FloatVectorFloatVector.fromMemorySegment(VectorSpecies<Float> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static FloatVectorFloatVector.fromMemorySegment(VectorSpecies<Float> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Float> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.static IntVectorIntVector.fromMemorySegment(VectorSpecies<Integer> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static IntVectorIntVector.fromMemorySegment(VectorSpecies<Integer> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Integer> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.static LongVectorLongVector.fromMemorySegment(VectorSpecies<Long> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static LongVectorLongVector.fromMemorySegment(VectorSpecies<Long> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Long> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.static ShortVectorShortVector.fromMemorySegment(VectorSpecies<Short> species, MemorySegment ms, long offset, ByteOrder bo) Loads a vector from a memory segment starting at an offset into the memory segment.static ShortVectorShortVector.fromMemorySegment(VectorSpecies<Short> species, MemorySegment ms, long offset, ByteOrder bo, VectorMask<Short> m) Loads a vector from a memory segment starting at an offset into the memory segment and using a mask.VectorSpecies.fromMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Loads a vector of this species from a memory segment starting at an offset into the memory segment.final voidByteVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidByteVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Byte> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.final voidDoubleVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidDoubleVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Double> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.final voidFloatVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidFloatVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Float> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.final voidIntVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidIntVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Integer> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.final voidLongVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidLongVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Long> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.final voidShortVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.final voidShortVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<Short> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.abstract voidVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) Stores this vector into a memory segment starting at an offset using explicit byte order.abstract voidVector.intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo, VectorMask<E> m) Stores this vector into a memory segment starting at an offset using explicit byte order and a mask.