Top Description Inners Fields Constructors Methods
jdk.internal.ref

public final Class CleanerImpl

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.lang.ref.Cleaner, .Cleaner.Cleanable, .ReferenceQueue, java.security.AccessController, .PrivilegedAction, java.util.concurrent.ThreadFactory, java.util.concurrent.atomic.AtomicInteger, java.util.function.Function, jdk.internal.misc.InnocuousThread

CleanerImpl manages a set of object references and corresponding cleaning actions. CleanerImpl provides the functionality of java.lang.ref.Cleaner.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
CleanerImpl.CleanerCleanable

A PhantomCleanable implementation for tracking the Cleaner itself.

pack-priv static class
CleanerImpl.InnocuousThreadFactory

A ThreadFactory for InnocuousThreads.

public static class
CleanerImpl.PhantomCleanableRef

Perform cleaning on an unreachable PhantomReference.

Field Summary

Modifier and TypeField and Description
private static Function<Cleaner, CleanerImpl>
cleanerImplAccess

An object to access the CleanerImpl from a Cleaner; set by Cleaner init.

pack-priv final PhantomCleanable<?>
phantomCleanableList

Heads of a CleanableList for each reference type.

pack-priv final ReferenceQueue<Object>

Constructor Summary

AccessConstructor and Description
public
CleanerImpl()

Constructor for CleanerImpl.

Method Summary

Modifier and TypeMethod and Description
pack-priv static CleanerImpl

Returns:

the corresponding CleanerImpl
getCleanerImpl
(Cleaner
the cleaner
cleaner
)

Called to get the CleanerImpl for a Cleaner.

public void
run()

Implements java.lang.Runnable.run.

Process queued Cleanables as long as the cleanable lists are not empty.

public static void
setCleanerImplAccess(Function<Cleaner, CleanerImpl>
a function to map from Cleaner to CleanerImpl
access
)

Called by Cleaner static initialization to provide the function to map from Cleaner to CleanerImpl.

public void
start(Cleaner
the cleaner
cleaner
,
ThreadFactory
the thread factory
threadFactory
)

Starts the Cleaner implementation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanerImplAccessback to summary
private static Function<Cleaner, CleanerImpl> cleanerImplAccess

An object to access the CleanerImpl from a Cleaner; set by Cleaner init.

phantomCleanableListback to summary
pack-priv final PhantomCleanable<?> phantomCleanableList

Heads of a CleanableList for each reference type.

queueback to summary
pack-priv final ReferenceQueue<Object> queue

Constructor Detail

CleanerImplback to summary
public CleanerImpl()

Constructor for CleanerImpl.

Method Detail

getCleanerImplback to summary
pack-priv static CleanerImpl getCleanerImpl(Cleaner cleaner)

Called to get the CleanerImpl for a Cleaner.

Parameters
cleaner:Cleaner

the cleaner

Returns:CleanerImpl

the corresponding CleanerImpl

runback to summary
public void run()

Implements java.lang.Runnable.run.

Process queued Cleanables as long as the cleanable lists are not empty. A Cleanable is in one of the lists for each Object and for the Cleaner itself. Terminates when the Cleaner is no longer reachable and has been cleaned and there are no more Cleanable instances for which the object is reachable.

If the thread is a ManagedLocalsThread, the threadlocals are erased before each cleanup

Annotations
@Override
setCleanerImplAccessback to summary
public static void setCleanerImplAccess(Function<Cleaner, CleanerImpl> access)

Called by Cleaner static initialization to provide the function to map from Cleaner to CleanerImpl.

Parameters
access:Function<Cleaner, CleanerImpl>

a function to map from Cleaner to CleanerImpl

startback to summary
public void start(Cleaner cleaner, ThreadFactory threadFactory)

Starts the Cleaner implementation. Ensure this is the CleanerImpl for the Cleaner. When started waits for Cleanables to be queued.

Parameters
cleaner:Cleaner

the cleaner

threadFactory:ThreadFactory

the thread factory

jdk.internal.ref back to summary

pack-priv final Class CleanerImpl.CleanerCleanable

extends PhantomCleanable<Cleaner>
Class Inheritance

A PhantomCleanable implementation for tracking the Cleaner itself.

Field Summary

Inherited from jdk.internal.ref.PhantomCleanable:
nextprev

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
performCleanup()

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

The performCleanup abstract method is overridden to implement the cleaning logic.

Inherited from jdk.internal.ref.PhantomCleanable:
cleanclearenqueueisEnqueuedisListEmpty

Constructor Detail

CleanerCleanableback to summary
pack-priv CleanerCleanable(Cleaner cleaner)

Method Detail

performCleanupback to summary
protected void performCleanup()

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

Doc from jdk.internal.ref.PhantomCleanable.performCleanup.

The performCleanup abstract method is overridden to implement the cleaning logic. The performCleanup method should not be called except by the clean method which ensures at most once semantics.

Annotations
@Override
jdk.internal.ref back to summary

pack-priv final Class CleanerImpl.InnocuousThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
All Implemented Interfaces
java.util.concurrent.ThreadFactory

A ThreadFactory for InnocuousThreads. The factory is a singleton.

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicInteger
pack-priv static final ThreadFactory

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static ThreadFactory
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
r
)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanerThreadNumberback to summary
pack-priv final AtomicInteger cleanerThreadNumber
factoryback to summary
pack-priv static final ThreadFactory factory

Constructor Detail

InnocuousThreadFactoryback to summary
pack-priv InnocuousThreadFactory()

Method Detail

factoryback to summary
pack-priv static ThreadFactory factory()
newThreadback to summary
public Thread newThread(Runnable r)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Parameters
r:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected

jdk.internal.ref back to summary

public final Class CleanerImpl.PhantomCleanableRef

extends PhantomCleanable<Object>
Class Inheritance

Perform cleaning on an unreachable PhantomReference.

Field Summary

Modifier and TypeField and Description
private final Runnable
Inherited from jdk.internal.ref.PhantomCleanable:
nextprev

Constructor Summary

AccessConstructor and Description
public
PhantomCleanableRef(Object
the object to monitor
obj
,
Cleaner
the cleaner
cleaner
,
Runnable
the action Runnable
action
)

Constructor for a phantom cleanable reference.

pack-priv
PhantomCleanableRef()

Constructor used only for root of phantom cleanable list.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides jdk.internal.ref.PhantomCleanable.clear.

Direct clearing of the referent is not supported.

public Object
get()

Overrides java.lang.ref.PhantomReference.get.

Prevent access to referent even when it is still alive.

protected void
performCleanup()

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

The performCleanup abstract method is overridden to implement the cleaning logic.

Inherited from jdk.internal.ref.PhantomCleanable:
cleanenqueueisEnqueuedisListEmpty

Field Detail

actionback to summary
private final Runnable action

Constructor Detail

PhantomCleanableRefback to summary
public PhantomCleanableRef(Object obj, Cleaner cleaner, Runnable action)

Constructor for a phantom cleanable reference.

Parameters
obj:Object

the object to monitor

cleaner:Cleaner

the cleaner

action:Runnable

the action Runnable

PhantomCleanableRefback to summary
pack-priv PhantomCleanableRef()

Constructor used only for root of phantom cleanable list.

Method Detail

clearback to summary
public void clear()

Overrides jdk.internal.ref.PhantomCleanable.clear.

Direct clearing of the referent is not supported.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
getback to summary
public Object get()

Overrides java.lang.ref.PhantomReference.get.

Prevent access to referent even when it is still alive.

Returns:Object

Doc from java.lang.ref.PhantomReference.get.

null

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
performCleanupback to summary
protected void performCleanup()

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

Doc from jdk.internal.ref.PhantomCleanable.performCleanup.

The performCleanup abstract method is overridden to implement the cleaning logic. The performCleanup method should not be called except by the clean method which ensures at most once semantics.

Annotations
@Override