com.google.common.base.FinalizableReference.
While this class is public, we consider it to be *internal* and not part of our published API. It is public so we can access it reflectively across class loaders in secure environments.
This class can't depend on other Google Collections code. If we were to load this class in the same class loader as the rest of Google Collections, this thread would keep an indirect strong reference to the class loader and prevent it from being garbage collected. This poses a problem for environments where you want to throw away the class loader. For example, dynamically reloading a web application or unloading an OSGi bundle.
com.google.common.base.FinalizableReferenceQueue loads this class
in its own class loader. That way, this class doesn't prevent the main
class loader from getting garbage collected, and this class can detect when
the main class loader has been garbage collected and stop itself.
| Modifier and Type | Field and Description |
|---|---|
| private static final String | FINALIZABLE_REFERENCE
Name of FinalizableReference.class. |
| private final WeakReference | |
| private final PhantomReference | |
| private static final Field | |
| private static final Constructor | |
| private static final Logger | |
| private final ReferenceQueue | |
| private Thread |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| private Method | |
| public static Constructor | |
| public static Field | |
| public void | run()
Implements java. |
| public void | |
| public static ReferenceQueue | Returns: ReferenceQueue which Finalizer will pollFinalizableReference.class finalizableReferenceClass, Object reference to instance of FinalizableReferenceQueue that started
this thread frq)Starts the Finalizer thread. |
| FINALIZABLE_REFERENCE | back to summary |
|---|---|
| private static final String FINALIZABLE_REFERENCE Name of FinalizableReference.class. | |
| finalizableReferenceClassReference | back to summary |
|---|---|
| private final WeakReference<Class<?>> finalizableReferenceClassReference | |
| frqReference | back to summary |
|---|---|
| private final PhantomReference<Object> frqReference | |
| inheritableThreadLocals | back to summary |
|---|---|
| private static final Field inheritableThreadLocals | |
| inheritableThreadlocalsConstructor | back to summary |
|---|---|
| private static final Constructor<Thread> inheritableThreadlocalsConstructor | |
| logger | back to summary |
|---|---|
| private static final Logger logger | |
| queue | back to summary |
|---|---|
| private final ReferenceQueue<Object> queue | |
| thread | back to summary |
|---|---|
| private Thread thread | |
| Finalizer | back to summary |
|---|---|
| private Finalizer(Class<?> finalizableReferenceClass, Object frq) Constructs a new finalizer thread. | |
| cleanUp | back to summary |
|---|---|
| private boolean cleanUp(Reference<?> reference) Cleans up a single reference. Catches and logs all throwables. | |
| getFinalizeReferentMethod | back to summary |
|---|---|
| private Method getFinalizeReferentMethod() Looks up FinalizableReference.finalizeReferent() method. | |
| getInheritableThreadLocalsConstructor | back to summary |
|---|---|
| public static Constructor | |
| getInheritableThreadLocalsField | back to summary |
|---|---|
| public static Field getInheritableThreadLocalsField() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Loops continuously, pulling references off the queue and cleaning them up.
| |
| start | back to summary |
|---|---|
| public void start() | |
| startFinalizer | back to summary |
|---|---|
| public static ReferenceQueue Starts the Finalizer thread. FinalizableReferenceQueue calls this method reflectively.
| |