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

public final Class IOUtil

extends Object
Class Inheritance
Imports
java.io.FileDescriptor, .IOException, java.nio.ByteBuffer, java.util.Objects, jdk.internal.access.JavaNioAccess, .SharedSecrets, jdk.internal.foreign.MemorySessionImpl

File-descriptor based I/O utilities that are shared by NIO classes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record
pack-priv static record

Field Summary

Modifier and TypeField and Description
pack-priv static final int
IOV_MAX

Max number of iovec structures that readv/writev supports

private static final JavaNioAccess
pack-priv static final long
WRITEV_MAX

Max total number of bytes that writev supports

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
acquireScope(ByteBuffer bb, boolean async)

pack-priv static Runnable
pack-priv static Runnable
pack-priv static long
pack-priv static native void
configureBlocking(int fd, boolean blocking)

public static void
configureBlocking(FileDescriptor fd, boolean blocking)

pack-priv static native boolean
drain(int fd)

Read and discard all bytes.

pack-priv static native int

Returns:

the number of bytes read or IOS_INTERRUPTED
drain1
(int fd)

Read and discard at most one byte

pack-priv static native int
public static native int
pack-priv static native void
pack-priv static native int
public static void
load()

Used to trigger loading of native libraries

pack-priv static native long
makePipe(boolean blocking)

Returns two file descriptors for a pipe encoded in a long.

public static FileDescriptor
newFD(int i)

pack-priv static native boolean
randomBytes(byte[] someBytes)

pack-priv static int
read(FileDescriptor fd, ByteBuffer dst, long position, NativeDispatcher nd)

pack-priv static int
read(FileDescriptor fd, ByteBuffer dst, long position, boolean async, NativeDispatcher nd)

pack-priv static int
read(FileDescriptor fd, ByteBuffer dst, long position, boolean directIO, int alignment, NativeDispatcher nd)

pack-priv static int
read(FileDescriptor fd, ByteBuffer dst, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

pack-priv static long
pack-priv static long
read(FileDescriptor fd, ByteBuffer[] bufs, boolean async, NativeDispatcher nd)

pack-priv static long
read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, NativeDispatcher nd)

pack-priv static long
read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, int alignment, NativeDispatcher nd)

pack-priv static long
read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

private static int
readIntoNativeBuffer(FileDescriptor fd, ByteBuffer bb, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

pack-priv static void
pack-priv static void
pack-priv static native void
setfdVal(FileDescriptor fd, int value)

pack-priv static int
write(FileDescriptor fd, ByteBuffer src, long position, NativeDispatcher nd)

pack-priv static int
write(FileDescriptor fd, ByteBuffer src, long position, boolean async, NativeDispatcher nd)

pack-priv static int
write(FileDescriptor fd, ByteBuffer src, long position, boolean directIO, int alignment, NativeDispatcher nd)

pack-priv static int
write(FileDescriptor fd, ByteBuffer src, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

pack-priv static long
write(FileDescriptor fd, ByteBuffer[] bufs, boolean async, NativeDispatcher nd)

pack-priv static long
write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, NativeDispatcher nd)

pack-priv static long
write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean direct, int alignment, NativeDispatcher nd)

pack-priv static long
write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

pack-priv static native int
write1(int fd, byte b)

private static int
writeFromNativeBuffer(FileDescriptor fd, ByteBuffer bb, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd)

pack-priv static native long
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IOV_MAXback to summary
pack-priv static final int IOV_MAX

Max number of iovec structures that readv/writev supports

NIO_ACCESSback to summary
private static final JavaNioAccess NIO_ACCESS
WRITEV_MAXback to summary
pack-priv static final long WRITEV_MAX

Max total number of bytes that writev supports

Constructor Detail

IOUtilback to summary
private IOUtil()

Method Detail

acquireScopeback to summary
pack-priv static void acquireScope(ByteBuffer bb, boolean async)
acquireScopesback to summary
pack-priv static Runnable acquireScopes(ByteBuffer[] buffers)
acquireScopesback to summary
pack-priv static Runnable acquireScopes(ByteBuffer buf, ByteBuffer[] buffers)
bufferAddressback to summary
pack-priv static long bufferAddress(ByteBuffer buf)
configureBlockingback to summary
pack-priv static native void configureBlocking(int fd, boolean blocking) throws IOException
configureBlockingback to summary
public static void configureBlocking(FileDescriptor fd, boolean blocking) throws IOException
drainback to summary
pack-priv static native boolean drain(int fd) throws IOException

Read and discard all bytes.

drain1back to summary
pack-priv static native int drain1(int fd) throws IOException

Read and discard at most one byte

Returns:int

the number of bytes read or IOS_INTERRUPTED

fdLimitback to summary
pack-priv static native int fdLimit()
fdValback to summary
public static native int fdVal(FileDescriptor fd)
initIDsback to summary
pack-priv static native void initIDs()
iovMaxback to summary
pack-priv static native int iovMax()
loadback to summary
public static void load()

Used to trigger loading of native libraries

makePipeback to summary
pack-priv static native long makePipe(boolean blocking) throws IOException

Returns two file descriptors for a pipe encoded in a long. The read end of the pipe is returned in the high 32 bits, while the write end is returned in the low 32 bits.

newFDback to summary
public static FileDescriptor newFD(int i)
randomBytesback to summary
pack-priv static native boolean randomBytes(byte[] someBytes)
readback to summary
pack-priv static int read(FileDescriptor fd, ByteBuffer dst, long position, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static int read(FileDescriptor fd, ByteBuffer dst, long position, boolean async, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static int read(FileDescriptor fd, ByteBuffer dst, long position, boolean directIO, int alignment, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static int read(FileDescriptor fd, ByteBuffer dst, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static long read(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static long read(FileDescriptor fd, ByteBuffer[] bufs, boolean async, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, int alignment, NativeDispatcher nd) throws IOException
readback to summary
pack-priv static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
readIntoNativeBufferback to summary
private static int readIntoNativeBuffer(FileDescriptor fd, ByteBuffer bb, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
releaseScopeback to summary
pack-priv static void releaseScope(ByteBuffer bb)
releaseScopesback to summary
pack-priv static void releaseScopes(Runnable releasers)
setfdValback to summary
pack-priv static native void setfdVal(FileDescriptor fd, int value)
writeback to summary
pack-priv static int write(FileDescriptor fd, ByteBuffer src, long position, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static int write(FileDescriptor fd, ByteBuffer src, long position, boolean async, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static int write(FileDescriptor fd, ByteBuffer src, long position, boolean directIO, int alignment, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static int write(FileDescriptor fd, ByteBuffer src, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static long write(FileDescriptor fd, ByteBuffer[] bufs, boolean async, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean direct, int alignment, NativeDispatcher nd) throws IOException
writeback to summary
pack-priv static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
write1back to summary
pack-priv static native int write1(int fd, byte b) throws IOException
writeFromNativeBufferback to summary
private static int writeFromNativeBuffer(FileDescriptor fd, ByteBuffer bb, long position, boolean directIO, boolean async, int alignment, NativeDispatcher nd) throws IOException
writevMaxback to summary
pack-priv static native long writevMax()
sun.nio.ch back to summary

pack-priv final Record IOUtil.LinkedRunnable

extends Record
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Record Components
node:Runnable 
next:Runnable 

Field Summary

Modifier and TypeField and Description
private final Runnable
next

Record Component accessed by next().

private final Runnable
node

Record Component accessed by node().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Runnable
next()

Record Component getter of next.

public Runnable
node()

Record Component getter of node.

pack-priv static IOUtil.LinkedRunnable
of(Runnable first, Runnable second)

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

nextback to summary
private final Runnable next

Record Component accessed by next().

nodeback to summary
private final Runnable node

Record Component accessed by node().

Constructor Detail

LinkedRunnableback to summary
pack-priv LinkedRunnable(Runnable node, Runnable next)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

nextback to summary
public Runnable next()

Record Component getter of next.

nodeback to summary
public Runnable node()

Record Component getter of node.

ofback to summary
pack-priv static IOUtil.LinkedRunnable of(Runnable first, Runnable second)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

sun.nio.ch back to summary

pack-priv final Record IOUtil.Releaser

extends Record
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Record Components
bb:ByteBuffer 

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
bb

Record Component accessed by bb().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
bb()

Record Component getter of bb.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

pack-priv static Runnable
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

bbback to summary
private final ByteBuffer bb

Record Component accessed by bb().

Constructor Detail

Releaserback to summary
pack-priv Releaser(ByteBuffer bb)

Method Detail

bbback to summary
public ByteBuffer bb()

Record Component getter of bb.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

ofback to summary
pack-priv static Runnable of(ByteBuffer bb)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.