com.sun.jini.jeri.internal.runtime
Class WeakKey

java.lang.Object
  extended by java.lang.ref.Reference<T>
      extended by java.lang.ref.WeakReference
          extended by com.sun.jini.jeri.internal.runtime.WeakKey

public final class WeakKey
extends WeakReference

WeakKey objects are used by the object table to hold weak references to DGC-enabled remote objects in the exported object table, so that such a remote object with no known client references may be (locally) garbage collected. In order for WeakKey objects to be used as keys in the object table, this class extends java.lang.ref.WeakReference to override the hashCode and equals methods such that WeakKey objects hash and compare to each other according to the identity of their referents. The identity-based comparison is necessary to insulate the runtime from arbitrary remote implementation classes' notions of object equality.

Author:
Sun Microsystems, Inc.

Field Summary
private  int hash
          saved value of the referent's identity hash code, to maintain a consistent hash code after the referent has been cleared
 
Constructor Summary
WeakKey(Object obj)
          Create a new WeakKey to the given object.
WeakKey(Object obj, ReferenceQueue refQueue)
          Create a new WeakKey to the given object, registered with a queue.
 
Method Summary
 boolean equals(Object obj)
          Returns true if the given object is this identical WeakKey instance, or, if this object's referent has not been cleared, if the given object is another WeakKey instance with the identical non-null referent as this one.
 int hashCode()
          Returns the identity hash code of the original referent.
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, get, isEnqueued
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hash

private final int hash
saved value of the referent's identity hash code, to maintain a consistent hash code after the referent has been cleared

Constructor Detail

WeakKey

public WeakKey(Object obj)
Create a new WeakKey to the given object.


WeakKey

public WeakKey(Object obj,
               ReferenceQueue refQueue)
Create a new WeakKey to the given object, registered with a queue.

Method Detail

hashCode

public int hashCode()
Returns the identity hash code of the original referent.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Returns true if the given object is this identical WeakKey instance, or, if this object's referent has not been cleared, if the given object is another WeakKey instance with the identical non-null referent as this one.

Overrides:
equals in class Object


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.