1. /*
  2. * @(#)WeakReference.java 1.8 01/11/29
  3. *
  4. * Copyright 2002 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.8, 01/11/29
  24. * @author Mark Reinhold
  25. * @since JDK1.2
  26. */
  27. public class WeakReference extends Reference {
  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. public WeakReference(Object referent) {
  33. super(referent);
  34. }
  35. /**
  36. * Creates a new weak reference that refers to the given object and is
  37. * registered with the given queue.
  38. *
  39. * @throws NullPointerException If the <code>queue</code> argument
  40. * is <code>null</code>
  41. *
  42. */
  43. public WeakReference(Object referent, ReferenceQueue q) {
  44. super(referent, q);
  45. }
  46. }