1. /*
  2. * @(#)WeakReference.java 1.18 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.lang.ref;
  8. /**
  9. * Weak reference objects, which do not prevent their referents from being
  10. * made finalizable, finalized, and then reclaimed. Weak references are most
  11. * often used to implement canonicalizing mappings.
  12. *
  13. * <p> Suppose that the garbage collector determines at a certain point in time
  14. * that an object is <a href="package-summary.html#reachability">weakly
  15. * reachable</a>. At that time it will atomically clear all weak references to
  16. * that object and all weak references to any other weakly-reachable objects
  17. * from which that object is reachable through a chain of strong and soft
  18. * references. At the same time it will declare all of the formerly
  19. * weakly-reachable objects to be finalizable. At the same time or at some
  20. * later time it will enqueue those newly-cleared weak references that are
  21. * registered with reference queues.
  22. *
  23. * @version 1.18, 12/19/03
  24. * @author Mark Reinhold
  25. * @since 1.2
  26. */
  27. public class WeakReference<T> extends Reference<T> {
  28. /**
  29. * Creates a new weak reference that refers to the given object. The new
  30. * reference is not registered with any queue.
  31. *
  32. * @param referent object the new weak reference will refer to
  33. */
  34. public WeakReference(T referent) {
  35. super(referent);
  36. }
  37. /**
  38. * Creates a new weak reference that refers to the given object and is
  39. * registered with the given queue.
  40. *
  41. * @param referent object the new weak reference will refer to
  42. * @param q the queue with which the reference is to be registered,
  43. * or <tt>null</tt> if registration is not required
  44. */
  45. public WeakReference(T referent, ReferenceQueue<? super T> q) {
  46. super(referent, q);
  47. }
  48. }