aicas logo Jamaica 3.4 release 8

java.lang.ref
Class PhantomReference<T>

java.lang.Object
  extended by java.lang.ref.Reference<T>
      extended by java.lang.ref.PhantomReference<T>

public class PhantomReference<T>
extends Reference<T>

PhantomReference is a reference that will get enqueued by the garbage collector when the referenced object is not reachable any longer and it cannot be resurrected again (in contrast to soft and weak references that can be resurrected by the execution of the finalizer after these references are cleared).

In JamaicaVM, phantom references are cleared by the finalizer thread or by any other thread calling Runtime.runFinalization(). So it must be ensured that sufficient CPU time is available to these threads to actually clear these references to ensure that the system does not run out of memory since it cannot reclaim non-cleared phantom references.

Since:
1.2

Constructor Summary
PhantomReference(T r, ReferenceQueue<? super T> q)
          Initialize this phantome reference instance.
 
Method Summary
 T get()
          For phantom references, get() always returns null.
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, finalize, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhantomReference

public PhantomReference(T r,
                        ReferenceQueue<? super T> q)
Initialize this phantome reference instance.

Parameters:
r - the object referenced by this reference.
q - the reference queue to add this reference to when it is enqueued, null for none (which would be useless here since the only effect a phantom reference has is that it will be enqueued when the object is unreachable).
Throws:
InternalError - for JamaicaVM: if r is allocated in ScopedMemory.
Method Detail

get

public T get()
For phantom references, get() always returns null.

Overrides:
get in class Reference<T>
Returns:
null.

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.