Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/rmi/transport/WeakRef.java
          +++ new/src/share/classes/sun/rmi/transport/WeakRef.java
↓ open down ↓ 33 lines elided ↑ open up ↑
  34   34   * This class extends the functionality of java.lang.ref.WeakReference in
  35   35   * several ways.  The methods pin() and unpin() can be used to set
  36   36   * whether the contained reference is strong or weak (it is weak upon
  37   37   * construction).  The hashCode() and equals() methods are overridden so
  38   38   * that WeakRef objects hash and compare to each other according to the
  39   39   * object identity of their referents.
  40   40   *
  41   41   * @author  Ann Wollrath
  42   42   * @author  Peter Jones
  43   43   */
  44      -class WeakRef extends WeakReference {
       44 +class WeakRef extends WeakReference<Object> {
  45   45  
  46   46      /** value of the referent's "identity" hash code */
  47   47      private int hashValue;
  48   48  
  49   49      /** strong reference to the referent, for when this WeakRef is "pinned" */
  50   50      private Object strongRef = null;
  51   51  
  52   52      /**
  53   53       * Create a new WeakRef to the given object.
  54   54       */
  55   55      public WeakRef(Object obj) {
  56   56          super(obj);
  57   57          setHashValue(obj);      // cache object's "identity" hash code
  58   58      }
  59   59  
  60   60      /**
  61   61       * Create a new WeakRef to the given object, registered with a queue.
  62   62       */
  63      -    public WeakRef(Object obj, ReferenceQueue q) {
       63 +    public WeakRef(Object obj, ReferenceQueue<Object> q) {
  64   64          super(obj, q);
  65   65          setHashValue(obj);      // cache object's "identity" hash code
  66   66      }
  67   67  
  68   68      /**
  69   69       * Pin the contained reference (make this a strong reference).
  70   70       */
  71   71      public synchronized void pin() {
  72   72          if (strongRef == null) {
  73   73              strongRef = get();
↓ open down ↓ 66 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX