APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.foreign

public final Class MappedMemorySegmentImpl

extends NativeMemorySegmentImpl
Class Inheritance
Annotations
@ValueBased
Imports
jdk.internal.ValueBased, jdk.internal.access.foreign.UnmapperProxy, jdk.internal.misc.ScopedMemoryAccess, java.nio.ByteBuffer

Implementation for a mapped memory segments. A mapped memory segment is a native memory segment, which additionally features an UnmapperProxy object. This object provides detailed information about the memory mapped segment, such as the file descriptor associated with the mapping. This information is crucial in order to correctly reconstruct a byte buffer object from the segment (see makeByteBuffer()).

Field Summary

Modifier and TypeField and Description
pack-priv static final ScopedMemoryAccess
private final UnmapperProxy
Inherited from jdk.internal.foreign.NativeMemorySegmentImpl:
min

Constructor Summary

AccessConstructor and Description
public
MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, MemorySessionImpl scope)

Method Summary

Modifier and TypeMethod and Description
public MappedMemorySegmentImpl
asSlice(long offset, long newSize)

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.asSlice.

Implements java.lang.foreign.MemorySegment.asSlice.

Returns a slice of this memory segment, at the given offset.

pack-priv MappedMemorySegmentImpl
dup(long offset, long size, boolean readOnly, MemorySessionImpl scope)

Overrides jdk.internal.foreign.NativeMemorySegmentImpl.dup.

public void
force()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.force.

Implements java.lang.foreign.MemorySegment.force.

Forces any changes made to the contents of this mapped segment to be written to the storage device described by the mapped segment's file descriptor.

public boolean
isLoaded()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.isLoaded.

Implements java.lang.foreign.MemorySegment.isLoaded.

Determines whether all the contents of this mapped segment are resident in physical memory.

public boolean
isMapped()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.isMapped.

Implements java.lang.foreign.MemorySegment.isMapped.

Returns true if this segment is a mapped segment.

public void
load()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.load.

Implements java.lang.foreign.MemorySegment.load.

Loads the contents of this mapped segment into physical memory.

pack-priv ByteBuffer
public void
unload()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.unload.

Implements java.lang.foreign.MemorySegment.unload.

Unloads the contents of this mapped segment from physical memory.

Inherited from jdk.internal.foreign.NativeMemorySegmentImpl:
addressheapBaseisNativemaxAlignMaskmaxByteAlignmentunsafeGetBaseunsafeGetOffset

Field Detail

SCOPED_MEMORY_ACCESSback to summary
pack-priv static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS
unmapperback to summary
private final UnmapperProxy unmapper

Constructor Detail

MappedMemorySegmentImplback to summary
public MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, MemorySessionImpl scope)

Method Detail

asSliceback to summary
public MappedMemorySegmentImpl asSlice(long offset, long newSize)

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.asSlice.

Implements java.lang.foreign.MemorySegment.asSlice.

Doc from java.lang.foreign.MemorySegment.asSlice.

Returns a slice of this memory segment, at the given offset. The returned segment's address is the address of this segment plus the given offset; its size is specified by the given argument.

Equivalent to the following code:

asSlice(offset, newSize, 1);
asSlice(offset, newSize, 1);

If this segment is read-only, the returned segment is also read-only.

The returned memory segment shares a region of backing memory with this segment. Hence, no memory will be allocated or freed by this method.

Annotations
@Override
dupback to summary
pack-priv MappedMemorySegmentImpl dup(long offset, long size, boolean readOnly, MemorySessionImpl scope)

Overrides jdk.internal.foreign.NativeMemorySegmentImpl.dup.

Annotations
@Override
forceback to summary
public void force()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.force.

Implements java.lang.foreign.MemorySegment.force.

Doc from java.lang.foreign.MemorySegment.force.

Forces any changes made to the contents of this mapped segment to be written to the storage device described by the mapped segment's file descriptor.

If the file descriptor associated with this mapped segment resides on a local storage device then when this method returns it is guaranteed that all changes made to this segment since it was created, or since this method was last invoked, will have been written to that device.

If the file descriptor associated with this mapped segment does not reside on a local device then no such guarantee is made.

If this segment was not mapped in read/write mode (java.nio.channels.FileChannel.MapMode#READ_WRITE) then invoking this method may have no effect. In particular, the method has no effect for segments mapped in read-only or private mapping modes. This method may or may not have an effect for implementation-specific mapping modes.

isLoadedback to summary
public boolean isLoaded()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.isLoaded.

Implements java.lang.foreign.MemorySegment.isLoaded.

Doc from java.lang.foreign.MemorySegment.isLoaded.

Determines whether all the contents of this mapped segment are resident in physical memory.

A return value of true implies that it is highly likely that all the data in this segment is resident in physical memory and may therefore be accessed without incurring any virtual-memory page faults or I/O operations. A return value of false does not necessarily imply that this segment's contents are not resident in physical memory.

The returned value is a hint, rather than a guarantee, because the underlying operating system may have paged out some of this segment's data by the time that an invocation of this method returns.

isMappedback to summary
public boolean isMapped()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.isMapped.

Implements java.lang.foreign.MemorySegment.isMapped.

Doc from java.lang.foreign.MemorySegment.isMapped.

Returns true if this segment is a mapped segment. A mapped memory segment is created e.g. using the FileChannel#map(FileChannel.MapMode, long, long, Arena) factory, or by wrapping a mapped byte buffer.

Annotations
@Override
loadback to summary
public void load()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.load.

Implements java.lang.foreign.MemorySegment.load.

Doc from java.lang.foreign.MemorySegment.load.

Loads the contents of this mapped segment into physical memory.

This method makes a best effort to ensure that, when it returns, the contents of this segment are resident in physical memory. Invoking this method may cause some number of page faults and I/O operations to occur.

makeByteBufferback to summary
pack-priv ByteBuffer makeByteBuffer()

Overrides jdk.internal.foreign.NativeMemorySegmentImpl.makeByteBuffer.

Annotations
@Override
unloadback to summary
public void unload()

Overrides jdk.internal.foreign.AbstractMemorySegmentImpl.unload.

Implements java.lang.foreign.MemorySegment.unload.

Doc from java.lang.foreign.MemorySegment.unload.

Unloads the contents of this mapped segment from physical memory.

This method makes a best effort to ensure that the contents of this segment are no longer resident in physical memory. Accessing this segment's contents after invoking this method may cause some number of page faults and I/O operations to occur (as this segment's contents might need to be paged back in).