public final class TruffleWeakReference<T> extends WeakReference<T>
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 WeakReference
Correct usage of weak references in compiled code paths :
static class MyNode extends Node {
@CompilationFinal private TruffleWeakReference| Constructor and Description |
|---|
TruffleWeakReference(T t)
Creates 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.
|
public TruffleWeakReference(T t)
WeakReference.WeakReference(Object)public TruffleWeakReference(T referent, ReferenceQueue<? super T> q)
WeakReference.WeakReference(Object, ReferenceQueue)