APIdia Launch Partner
Top Description Fields Constructors Methods
sun.rmi.transport

pack-priv Class WeakRef

extends WeakReference<Object>
Class Inheritance
Imports
java.lang.ref.*, sun.rmi.runtime.Log

WeakRef objects are used by the RMI runtime to hold potentially weak references to exported remote objects in the local object table. This class extends the functionality of java.lang.ref.WeakReference in several ways. The methods pin() and unpin() can be used to set whether the contained reference is strong or weak (it is weak upon construction). The hashCode() and equals() methods are overridden so that WeakRef objects hash and compare to each other according to the object identity of their referents.
Authors
Ann Wollrath, Peter Jones

Field Summary

Modifier and TypeField and Description
private int
hashValue

value of the referent's "identity" hash code

private Object
strongRef

strong reference to the referent, for when this WeakRef is "pinned"

Constructor Summary

AccessConstructor and Description
public
WeakRef(Object obj)

Create a new WeakRef to the given object.

public
WeakRef(Object obj, ReferenceQueue<Object> q)

Create a new WeakRef to the given object, registered with a queue.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Return true if "obj" is this identical WeakRef object, or, if the contained reference has not been cleared, if "obj" is another WeakRef object with the identical non-null referent.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Always return the "identity" hash code of the original referent.

public synchronized void
pin()

Pin the contained reference (make this a strong reference).

private void
public synchronized void
unpin()

Unpin the contained reference (make this a weak reference).

Field Detail

hashValueback to summary
private int hashValue

value of the referent's "identity" hash code

strongRefback to summary
private Object strongRef

strong reference to the referent, for when this WeakRef is "pinned"

Constructor Detail

WeakRefback to summary
public WeakRef(Object obj)

Create a new WeakRef to the given object.

WeakRefback to summary
public WeakRef(Object obj, ReferenceQueue<Object> q)

Create a new WeakRef to the given object, registered with a queue.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Return true if "obj" is this identical WeakRef object, or, if the contained reference has not been cleared, if "obj" is another WeakRef object with the identical non-null referent. Otherwise, return false.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Always return the "identity" hash code of the original referent.

pinback to summary
public synchronized void pin()

Pin the contained reference (make this a strong reference).

setHashValueback to summary
private void setHashValue(Object obj)
unpinback to summary
public synchronized void unpin()

Unpin the contained reference (make this a weak reference).