FileDocCategorySizeDatePackage
Reference.javaAPI DocAndroid 1.5 API5218Wed May 06 22:41:04 BST 2009java.lang.ref

Reference

public abstract class Reference extends Object
Provides an abstract class which describes behavior common to all reference objects. It is not possible to create immediate subclasses of {@code Reference} in addition to the ones provided by this package. It is also not desirable to do so, since references require very close cooperation with the system's garbage collector. The existing, specialized reference classes should be used instead.
since
Android 1.0

Fields Summary
T
referent
The object to which this reference refers. VM requirement: this field must be called "referent" and be an object.
ReferenceQueue
queue
If non-null, the queue on which this reference will be enqueued when the referent is appropriately reachable. VM requirement: this field must be called "queue" and be a java.lang.ref.ReferenceQueue.
Reference
queueNext
Used internally by java.lang.ref.ReferenceQueue. VM requirement: this field must be called "queueNext" and be a java.lang.ref.Reference.
private int
vmData
Used internally by Dalvik. VM requirement: this field must be called "vmData" and be an int.
Constructors Summary
Reference()
Constructs a new instance of this class.

        super();
    
Methods Summary
public voidclear()
Makes the referent {@code null}. This does not force the reference object to be enqueued.

since
Android 1.0

        referent = null;
    
public booleanenqueue()
Forces the reference object to be enqueued if it has been associated with a queue.

return
{@code true} if this call has caused the {@code Reference} to become enqueued, or {@code false} otherwise
since
Android 1.0

        return enqueueInternal();
    
private synchronized booleanenqueueInternal()
An implementation of .enqueue() that is safe for the VM to call. If a Reference object is a subclass of any of the java.lang.ref.*Reference classes and that subclass overrides enqueue(), the VM may not call the overridden method. VM requirement: this method must be called "enqueueInternal", have the signature "()Z", and be private.

return
{@code true} if this call has caused the {@code Reference} to become enqueued, or {@code false} otherwise
since
Android 1.0

        /* VM requirement:
         * The VM assumes that this function only does work
         * if "(queue != null && queueNext == null)".
         * If that changes, Dalvik needs to change, too.
         * (see MarkSweep.c:enqueueReference())
         */
        if (queue != null && queueNext == null) {
            queue.enqueue(this);
            queue = null;
            return true;
        }
        return false;
    
public Tget()
Returns the referent of the reference object.

return
the referent to which reference refers, or {@code null} if the object has been cleared.
since
Android 1.0

        return referent;
    
public booleanisEnqueued()
Checks whether the reference object has been enqueued.

return
{@code true} if the {@code Reference} has been enqueued, {@code false} otherwise
since
Android 1.0

        return queueNext != null;