public class PinnedObjectImpl extends Object implements org.graalvm.nativeimage.PinnedObject
This class implements AutoCloseable
so that the pinning can be managed conveniently with
a try-with-resource block that releases the pinning automatically:
int[] array = ... try (PinnedObject pin = PinnedObject.open(array)) { CIntPointer rawData = pin.addressOfArrayElement(0); // it is safe to pass rawData to a C function. }TODO: Is pinning a service of all collectors, or just the one I have now?
Modifier | Constructor and Description |
---|---|
protected |
PinnedObjectImpl(Object object)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T extends org.graalvm.word.PointerBase> |
addressOfArrayElement(int index) |
org.graalvm.word.Pointer |
addressOfObject() |
static PinnedObjectImpl |
claimPinnedObjectList()
Claim the entire list.
|
void |
close()
Releases the pin for the object.
|
PinnedObjectImpl |
getNext() |
Object |
getObject() |
boolean |
isOpen() |
static PinnedObjectImpl |
pushPinnedObject(PinnedObjectImpl newHead)
Push an element onto the list.
|
protected void |
setNext(PinnedObjectImpl nextPinnedObject) |
protected PinnedObjectImpl(Object object)
public void close()
close
in interface AutoCloseable
close
in interface org.graalvm.nativeimage.PinnedObject
public Object getObject()
getObject
in interface org.graalvm.nativeimage.PinnedObject
public org.graalvm.word.Pointer addressOfObject()
addressOfObject
in interface org.graalvm.nativeimage.PinnedObject
public <T extends org.graalvm.word.PointerBase> T addressOfArrayElement(int index)
addressOfArrayElement
in interface org.graalvm.nativeimage.PinnedObject
public boolean isOpen()
public PinnedObjectImpl getNext()
protected void setNext(PinnedObjectImpl nextPinnedObject)
public static PinnedObjectImpl pushPinnedObject(PinnedObjectImpl newHead)
public static PinnedObjectImpl claimPinnedObjectList()