Top Description Inners Fields Constructors Methods
org.jboss.modules.ref

public final Class References

extends Object
Class Inheritance
Imports
java.lang.ref.ReferenceQueue

A set of utility methods for reference types.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Reference<T, A>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the reference value type
T
,
the reference attachment type
A
>
Reference<T, A>

Returns:

the reference
create
(Reference.Type
the reference type
type
,
T
the reference value
value
,
A
the attachment value
attachment
,
Reaper<T, A>
the reaper to use, if any
reaper
)

Create a reference of a given type with the provided value and attachment.

public static <
the reference value type
T
,
the reference attachment type
A
>
Reference<T, A>

Returns:

the reference
create
(Reference.Type
the reference type
type
,
T
the reference value
value
,
A
the attachment value
attachment
,
ReferenceQueue<? super T>
the reference queue to use, if any
referenceQueue
)

Create a reference of a given type with the provided value and attachment.

public static <
the reference value type
T
,
the reference attachment type
A
>
Reference<T, A>

Returns:

the reference
create
(Reference.Type
the reference type
type
,
T
the reference value
value
,
A
the attachment value
attachment
)

Create a reference of a given type with the provided value and attachment.

public static <
the reference value type
T
,
the attachment value type
A
>
Reference<T, A>

Returns:

the null reference
getNullReference
()

Get a null reference.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NULLback to summary
private static final Reference<T, A> NULL
Annotations
@SuppressWarnings:RawUseOfParameterizedType

Constructor Detail

Referencesback to summary
private References()

Method Detail

createback to summary
public static <T, A> Reference<T, A> create(Reference.Type type, T value, A attachment, Reaper<T, A> reaper)

Create a reference of a given type with the provided value and attachment. If the reference type is Reference.Type#STRONG or Reference.Type#NULL then the reaper argument is ignored. If the reference type is Reference.Type#NULL then the value and attachment arguments are ignored.

Parameters
<T>
the reference value type
<A>
the reference attachment type
type:Reference.Type

the reference type

value:T

the reference value

attachment:A

the attachment value

reaper:Reaper<T, A>

the reaper to use, if any

Returns:Reference<T, A>

the reference

createback to summary
public static <T, A> Reference<T, A> create(Reference.Type type, T value, A attachment, ReferenceQueue<? super T> referenceQueue)

Create a reference of a given type with the provided value and attachment. If the reference type is Reference.Type#STRONG or Reference.Type#NULL then the reference queue argument is ignored. If the reference type is Reference.Type#NULL then the value and attachment arguments are ignored.

Parameters
<T>
the reference value type
<A>
the reference attachment type
type:Reference.Type

the reference type

value:T

the reference value

attachment:A

the attachment value

referenceQueue:ReferenceQueue<? super T>

the reference queue to use, if any

Returns:Reference<T, A>

the reference

createback to summary
public static <T, A> Reference<T, A> create(Reference.Type type, T value, A attachment) throws IllegalArgumentException

Create a reference of a given type with the provided value and attachment. If the reference type is Reference.Type#PHANTOM then this method will throw an IllegalArgumentException because such references are not constructable without a queue or reaper. If the reference type is Reference.Type#NULL then the value and attachment arguments are ignored.

Parameters
<T>
the reference value type
<A>
the reference attachment type
type:Reference.Type

the reference type

value:T

the reference value

attachment:A

the attachment value

Returns:Reference<T, A>

the reference

Exceptions
IllegalArgumentException:
if the reference type is Reference.Type#PHANTOM
getNullReferenceback to summary
public static <T, A> Reference<T, A> getNullReference()

Get a null reference. This reference type is always cleared and does not retain an attachment; as such there is only one single instance of it.

Parameters
<T>
the reference value type
<A>
the attachment value type
Returns:Reference<T, A>

the null reference

Annotations
@SuppressWarnings:unchecked
org.jboss.modules.ref back to summary

pack-priv final Class References.ReaperThread

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final ReferenceQueue<Object>
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static <T, A> void
reap(final Reapable<T, A> reapable)

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

REAPER_QUEUEback to summary
pack-priv static final ReferenceQueue<Object> REAPER_QUEUE

Constructor Detail

ReaperThreadback to summary
pack-priv ReaperThread()

Method Detail

reapback to summary
private static <T, A> void reap(final Reapable<T, A> reapable)
Annotations
@SuppressWarnings:unchecked
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.