APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.nio.ch

public Class FileChannelImpl

extends FileChannel
Class Inheritance
Imports
java.io.Closeable, .FileDescriptor, .IOException, .UncheckedIOException, java.lang.foreign.MemorySegment, .Arena, java.lang.ref.Cleaner.Cleanable, java.nio.ByteBuffer, .MappedByteBuffer, java.nio.channels.AsynchronousCloseException, .Channel, .ClosedByInterruptException, .ClosedChannelException, .FileChannel, .FileLock, .FileLockInterruptionException, .NonReadableChannelException, .NonWritableChannelException, .ReadableByteChannel, .SelectableChannel, .WritableByteChannel, java.util.Objects, jdk.internal.access.JavaIOFileDescriptorAccess, .SharedSecrets, jdk.internal.event.FileForceEvent, .FileReadEvent, .FileWriteEvent, jdk.internal.foreign.MemorySessionImpl, .SegmentFactories, jdk.internal.misc.Blocker, .ExtendedMapMode, .Unsafe, .VM, .VM.BufferPool, jdk.internal.ref.CleanerFactory, jdk.internal.access.foreign.UnmapperProxy, sun.nio.Cleaner

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private abstract static class

Field Summary

Modifier and TypeField and Description
private final int
private final Cleaner.Cleanable
private final boolean
private final FileDescriptor
private static final JavaIOFileDescriptorAccess
private volatile FileLockTable
private static boolean
private static final int
private static final int
private static final int
private static final int
private static final long
private static final long
private static final FileDispatcher
private final Closeable
private final String
private final Object
private final boolean
private final boolean
private final NativeThreadSet
private static final int
private static volatile boolean
private static volatile boolean
private volatile boolean
private final boolean

Constructor Summary

AccessConstructor and Description
private
FileChannelImpl(FileDescriptor fd, String path, boolean readable, boolean writable, boolean sync, boolean direct, Closeable parent)

Method Summary

Modifier and TypeMethod and Description
private void
afterTransfer(boolean completed, int ti)

Marks the end of a transfer to or from this channel.

pack-priv int
available()

Returns an estimate of the number of remaining bytes that can be read from this channel without blocking.

private int
beforeTransfer()

Marks the beginning of a transfer to or from this channel.

private void
private void
checkMode(FileChannel.MapMode mode, int prot, boolean isSync)

private void
endBlocking(boolean completed)

private void
private FileLockTable
public void
force(boolean metaData)

Implements abstract java.nio.channels.FileChannel.force.

Forces any updates to this channel's file to be written to the storage device that contains it.

public static VM.BufferPool
getMappedBufferPool()

Invoked by sun.management.ManagementFactoryHelper to create the management interface for mapped buffers.

public static VM.BufferPool
getSyncMappedBufferPool()

Invoked by sun.management.ManagementFactoryHelper to create the management interface for sync mapped buffers.

protected void
private void
implForce(boolean metaData)

private int
private long
implRead(ByteBuffer[] dsts, int offset, int length)

private int
implRead(ByteBuffer dst, long position)

private int
private long
implWrite(ByteBuffer[] srcs, int offset, int length)

private int
implWrite(ByteBuffer src, long position)

pack-priv boolean
isOther()

Tells whether the channel represents something other than a regular file, directory, or symbolic link.

private boolean
public FileLock
lock(long position, long size, boolean shared)

Implements abstract java.nio.channels.FileChannel.lock.

Acquires a lock on the given region of this channel's file.

public MappedByteBuffer
map(FileChannel.MapMode mode, long position, long size)

Implements abstract java.nio.channels.FileChannel.map.

Maps a region of this channel's file directly into memory.

public MemorySegment
map(FileChannel.MapMode mode, long offset, long size, Arena arena)

Overrides java.nio.channels.FileChannel.map.

Maps a region of this channel's file into a new mapped memory segment, with the given offset, size and arena.

private FileChannelImpl.Unmapper
mapInternal(FileChannel.MapMode mode, long position, long size, int prot, boolean isSync)

public static FileChannel
open(FileDescriptor fd, String path, boolean readable, boolean writable, boolean sync, boolean direct, Closeable parent)

public long
position()

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Returns this channel's file position.

public FileChannel
position(long newPosition)

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Sets this channel's file position.

public int
read(ByteBuffer dst)

Implements abstract java.nio.channels.FileChannel.read.

Implements java.nio.channels.SeekableByteChannel.read, java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

public long
read(ByteBuffer[] dsts, int offset, int length)

Implements abstract java.nio.channels.FileChannel.read.

Implements java.nio.channels.ScatteringByteChannel.read.

Reads a sequence of bytes from this channel into a subsequence of the given buffers.

public int
read(ByteBuffer dst, long position)

Implements abstract java.nio.channels.FileChannel.read.

Reads a sequence of bytes from this channel into the given buffer, starting at the given file position.

private int
readInternal(ByteBuffer dst, long position)

pack-priv void
public void
public long
size()

Implements abstract java.nio.channels.FileChannel.size.

Implements java.nio.channels.SeekableByteChannel.size.

Returns the current size of this channel's file.

private int
private int
private long
traceImplRead(ByteBuffer[] dsts, int offset, int length)

private int
traceImplRead(ByteBuffer dst, long position)

private int
private long
traceImplWrite(ByteBuffer[] srcs, int offset, int length)

private int
traceImplWrite(ByteBuffer src, long position)

private AsynchronousCloseException
transferFailed(ClosedChannelException cce, Channel other)

Invoked when ClosedChannelException is thrown during a transfer.

public long
transferFrom(ReadableByteChannel src, long position, long count)

Implements abstract java.nio.channels.FileChannel.transferFrom.

Transfers bytes into this channel's file from the given readable byte channel.

private long
transferFromArbitraryChannel(ReadableByteChannel src, long position, long count)

Transfers bytes into this channel's file from the given channel.

private long
transferFromDirect(FileChannelImpl src, long position, long count)

Transfers bytes into this channel's file from the given channel's file.

private long
transferFromFileChannel(FileChannelImpl src, long position, long count)

Transfers bytes into this channel's file from the given channel's file.

private long
transferFromFileDescriptor(FileDescriptor srcFD, long position, long count)

Transfers bytes into this channel's file from the resource that the given file descriptor is connected to.

public long
transferTo(long position, long count, WritableByteChannel target)

Implements abstract java.nio.channels.FileChannel.transferTo.

Transfers bytes from this channel's file to the given writable byte channel.

private long
transferToArbitraryChannel(long position, long count, WritableByteChannel target)

Transfers bytes from channel's file to the given channel.

private long

Returns:

the number of bytes transferred, UNSUPPORTED_CASE if this transfer cannot be done directly, or UNSUPPORTED if there is no direct support
transferToDirect
(long position, int count, WritableByteChannel target)

Transfers bytes from this channel's file to the given channel's file or socket.

private long
transferToDirectInternal(long position, int count, WritableByteChannel target)

Transfers bytes from this channel's file from the given channel's file.

private long
transferToFileChannel(long position, int count, FileChannelImpl target)

Transfers bytes from this channel's file to the given channel's file.

private long
transferToFileDescriptor(long position, int count, FileDescriptor targetFD)

Transfers bytes from this channel's file to the resource that the given file descriptor is connected to.

private long
transferToSocketChannel(long position, int count, SocketChannelImpl target)

Transfers bytes from this channel's file to the given channel's socket.

private long
transferToTrustedChannel(long position, long count, WritableByteChannel target)

Transfers bytes from channel's file to the given channel.

public FileChannel
truncate(long newSize)

Implements abstract java.nio.channels.FileChannel.truncate.

Implements java.nio.channels.SeekableByteChannel.truncate.

Truncates this channel's file to the given size.

public FileLock
tryLock(long position, long size, boolean shared)

Implements abstract java.nio.channels.FileChannel.tryLock.

Attempts to acquire a lock on the given region of this channel's file.

private static void
public int
write(ByteBuffer src)

Implements abstract java.nio.channels.FileChannel.write.

Implements java.nio.channels.SeekableByteChannel.write, java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

public long
write(ByteBuffer[] srcs, int offset, int length)

Implements abstract java.nio.channels.FileChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from a subsequence of the given buffers.

public int
write(ByteBuffer src, long position)

Implements abstract java.nio.channels.FileChannel.write.

Writes a sequence of bytes to this channel from the given buffer, starting at the given file position.

private int
writeInternal(ByteBuffer src, long position)

Inherited from java.nio.channels.FileChannel:
lockopenopenreadtryLockwrite