APIdia Launch Partner
Top Description Fields Constructors Methods
java.io

pack-priv final Class FileCleanable

extends PhantomCleanable<FileDescriptor>
Class Inheritance
Imports
jdk.internal.access.JavaIOFileDescriptorAccess, .SharedSecrets, jdk.internal.ref.CleanerFactory, .PhantomCleanable, java.lang.ref.Cleaner

Cleanable for a FileDescriptor when it becomes phantom reachable. For regular fds on Unix and regular handles on Windows register a cleanup if fd != -1 or handle != -1.

Subclassed from PhantomCleanable so that clear can be called to disable the cleanup when the handle is closed by any means other than calling FileDescriptor#close. Otherwise, it might incorrectly close the handle after it has been reused.

Field Summary

Modifier and TypeField and Description
private final int
private static final JavaIOFileDescriptorAccess
private final long

Constructor Summary

AccessConstructor and Description
private
FileCleanable(FileDescriptor
the object to monitor
obj
,
Cleaner
the cleaner
cleaner
,
int
file descriptor to close
fd
,
long
handle to close
handle
)

Constructor for a phantom cleanable reference.

Method Summary

Modifier and TypeMethod and Description
private static native void
cleanupClose0(int fd, long handle)

protected void
performCleanup()

Implements abstract jdk.internal.ref.PhantomCleanable.performCleanup.

Close the native handle or fd.

pack-priv static void
register(FileDescriptor
the FileDescriptor; may be null
fdo
)

Register a Cleanable with the FileDescriptor if the FileDescriptor is non-null and valid.

pack-priv static void
unregister(FileDescriptor
the FileDescriptor; may be null
fdo
)

Unregister a Cleanable from the FileDescriptor.

Inherited from jdk.internal.ref.PhantomCleanable:
cleanclearenqueueisEnqueued

Field Detail

fdback to summary
private final int fd
fdAccessback to summary
private static final JavaIOFileDescriptorAccess fdAccess
handleback to summary
private final long handle

Constructor Detail

FileCleanableback to summary
private FileCleanable(FileDescriptor obj, Cleaner cleaner, int fd, long handle)

Constructor for a phantom cleanable reference.

Parameters
obj:FileDescriptor

the object to monitor

cleaner:Cleaner

the cleaner

fd:int

file descriptor to close

handle:long

handle to close

Method Detail

cleanupClose0back to summary
private static native void cleanupClose0(int fd, long handle) throws IOException
performCleanupback to summary
protected void performCleanup()

Implements abstract jdk.internal.ref.PhantomCleanable.performCleanup.

Close the native handle or fd.

Annotations
@Override
registerback to summary
pack-priv static void register(FileDescriptor fdo)

Register a Cleanable with the FileDescriptor if the FileDescriptor is non-null and valid.

Implementation Note

An exception (OutOfMemoryException) will leave the FileDescriptor having allocated resources and leak the fd/handle.

Parameters
fdo:FileDescriptor

the FileDescriptor; may be null

unregisterback to summary
pack-priv static void unregister(FileDescriptor fdo)

Unregister a Cleanable from the FileDescriptor.

Parameters
fdo:FileDescriptor

the FileDescriptor; may be null