home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 2.1 KB | 69 lines |
- /*
- * @(#)PhantomReference.java 1.4 98/03/18
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- package java.lang.ref;
-
-
- /**
- * Phantom reference objects, for use in scheduling pre-mortem cleanup
- * actions.
- *
- * <p> A <i>phantom</i> 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.
- *
- * <p> In order to ensure that a reclaimable object remains so, the referent of
- * a phantom reference may not be retrieved: The <code>get</code> method of a
- * phantom reference always returns <code>null</code>.
- *
- * @author Mark Reinhold
- * @see java.lang.ref.Reference
- * @since JDK1.2
- */
-
- public class PhantomReference extends Reference {
-
- /**
- * Return <code>null</code>, since the referent of a phantom reference
- * is always inaccessible.
- */
- public Object get() {
- return null;
- }
-
- /**
- * Create a new phantom reference that refers to the given object.
- * The new reference is not registered with any queue.
- */
- public PhantomReference(Object referent) {
- super(referent);
- }
-
- /**
- * Create a new phantom reference that refers to the given object and
- * is registered with the given queue.
- *
- * @exception NullPointerException If the <code>queue</code> argument
- * is <code>null</code>
- */
- public PhantomReference(Object referent, ReferenceQueue q) {
- super(referent, q);
- this.state = ACTIVE;
- }
-
- }
-