home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / rmi / transport / WeakRef.class (.txt) < prev   
Encoding:
Java Class File  |  1997-07-08  |  1.4 KB  |  64 lines

  1. package sun.rmi.transport;
  2.  
  3. import java.rmi.server.LogStream;
  4. import sun.misc.Ref;
  5.  
  6. public class WeakRef extends Ref {
  7.    private int hashValue;
  8.    private Object hardref;
  9.  
  10.    public WeakRef(Object var1) {
  11.       this.hashValue = var1.hashCode();
  12.       this.setThing(var1);
  13.    }
  14.  
  15.    public synchronized void pin() {
  16.       if (this.hardref == null) {
  17.          if (DGCImpl.logLevel >= 20) {
  18.             LogStream.log("dgc").println("WeakRef.pin: ref = " + this);
  19.          }
  20.  
  21.          this.hardref = ((Ref)this).check();
  22.       }
  23.  
  24.    }
  25.  
  26.    public synchronized void unpin() {
  27.       if (((Ref)this).check() == null && this.hardref != null) {
  28.          if (DGCImpl.logLevel >= 20) {
  29.             LogStream.log("dgc").println("WeakRef.unpin: ref = " + this);
  30.          }
  31.  
  32.          this.setThing(this.hardref);
  33.       }
  34.  
  35.       this.hardref = null;
  36.    }
  37.  
  38.    public Object reconstitute() {
  39.       return this.hardref;
  40.    }
  41.  
  42.    public synchronized void setThing(Object var1) {
  43.       this.hashValue = var1.hashCode();
  44.       super.setThing(var1);
  45.       if (this.hardref != null) {
  46.          this.hardref = var1;
  47.       }
  48.  
  49.    }
  50.  
  51.    public int hashCode() {
  52.       return this.hashValue;
  53.    }
  54.  
  55.    public boolean equals(Object var1) {
  56.       if (var1 == this) {
  57.          return true;
  58.       } else {
  59.          Object var2 = ((Ref)this).get();
  60.          return var2 != null && var2 == var1;
  61.       }
  62.    }
  63. }
  64.