Class TruffleWeakReference<T>
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.WeakReference<T>
com.oracle.truffle.api.utilities.TruffleWeakReference<T>
Creates a new weak reference that is safe to be used in compiled code paths. If a weak reference
is
PE constant
then the
referenced object
will be
PE constant
as well.
When a language is compiled using native-image then a closed world closure of all runtime compiled methods is computed. That list of methods can rely on static type information only. If the host application or any of the loaded libraries uses custom weak reference sub-classes that were not designed for partial evaluation then these method will be listed as runtime compilable methods, causing black listed method errors at native-image compilation time. To avoid this problem use this custom weak reference subclass which is designed for PE if used as exact class of the field.
Wrong usage of weak references in compiled code paths:
class MyNode extends Node { @CompilationFinal private WeakReferenceCorrect usage of weak references in compiled code paths :
static class MyNode extends Node { @CompilationFinal private TruffleWeakReference
- Since:
- 20.2
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Truffle weak reference that refers to the given object.TruffleWeakReference
(T referent, ReferenceQueue<? super T> q) Creates a new Truffle weak reference that refers to the given object and is registered with the given queue. -
Method Summary
Methods inherited from class Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence, refersTo
-
Constructor Details
-
TruffleWeakReference
Creates a new Truffle weak reference that refers to the given object. The new reference is not registered with any queue.- Since:
- 20.2
- See Also:
-
TruffleWeakReference
Creates a new Truffle weak reference that refers to the given object and is registered with the given queue.- Since:
- 20.2
- See Also:
-