All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.lang.ref.PhantomReference

java.lang.Object
    |
    +----java.lang.ref.Reference
            |
            +----java.lang.ref.PhantomReference

public class PhantomReference
extends Reference
Phantom reference objects, for use in scheduling post-mortem cleanup actions.

A phantom reference is a reference object that remains valid even after the collector determines that its referent may be reclaimed. If a phantom reference is registered and the garbage collector determines at a certain point in time that its referent is no longer strongly reachable, has no guarded or weak references, and has been finalized, then at some later time the collector will enqueue the reference.

In order to ensure that a reclaimable object remains so, the referent of a phantom reference may not be retrieved: The get method of a phantom reference always returns null.

Since:
JDK1.2
See Also:
Reference

Constructor Index

 o PhantomReference(Object)
Create a new phantom reference that refers to the given object.
 o PhantomReference(Object, ReferenceQueue)
Create a new phantom reference that refers to the given object and is registered with the given queue.

Method Index

 o get()
Return null, since the referent of a phantom reference is always inaccessible.

Constructors

 o PhantomReference
public PhantomReference(Object referent)
Create a new phantom reference that refers to the given object. The new reference is not registered with any queue.

 o PhantomReference
public PhantomReference(Object referent,
                        ReferenceQueue q)
Create a new phantom reference that refers to the given object and is registered with the given queue.

Throws: NullPointerException
If the queue argument is null

Methods

 o get
public Object get()
Return null, since the referent of a phantom reference is always inaccessible.

Overrides:
get in class Reference

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature