Top Description Inners Fields Constructors Methods
org.graalvm.nativebridge

public final Class NativeIsolate

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Collections, .Map, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger

Represents a single native image isolate. All NativeObjects have a NativeIsolate context.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final ThreadLocal<NativeIsolateThread>
pack-priv final Set<NativeObjectCleaner<?>>
pack-priv static final int
private final JNIConfig
private final long
private static final Map<Long, NativeIsolate>
private static final long
private volatile NativeIsolate.State
private final Collection<NativeIsolateThread>
private final long
private static final AtomicInteger

Constructor Summary

AccessConstructor and Description
private
NativeIsolate(long isolateId, JNIConfig config)

Method Summary

Modifier and TypeMethod and Description
public void
private synchronized void
detachThread(NativeIsolateThread nativeIsolateThread)

private boolean
public NativeIsolateThread
enter()

Enters this NativeIsolate on the current thread.

public static NativeIsolate

Returns:

the newly created NativeIsolate for the isolateId.
forIsolateId
(long isolateId, JNIConfig config)

Creates a NativeIsolate for the isolateId and JNIConfig.

public static NativeIsolate

Returns:

NativeIsolate object for the entered isolate with the specified isolate address
get
(long
id of an entered isolate
isolateId
)

Gets the NativeIsolate object for the entered isolate with the specified isolate address.

public JNIConfig
getConfig()

Returns the JNIConfig used by this NativeIsolate.

public long
getIsolateId()

Returns the isolate address.

private NativeIsolateThread
public boolean
isActive()

Returns true if the current thread is entered to this NativeIsolate.

public boolean
pack-priv void
public void
registerNativeThread(long
the isolate thread to bind.
isolateThreadId
)

Binds a native image thread to this isolate.

public boolean
shutdown()

Requests an isolate shutdown.

pack-priv RuntimeException
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public NativeIsolateThread

Returns:

NativeIsolateThread on success or null when this NativeIsolate is closed or being closed.
tryEnter
()

Tries to enter this NativeIsolate on the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attachedIsolateThreadback to summary
private final ThreadLocal<NativeIsolateThread> attachedIsolateThread
cleanersback to summary
pack-priv final Set<NativeObjectCleaner<?>> cleaners
CLOSEDback to summary
pack-priv static final int CLOSED
configback to summary
private final JNIConfig config
isolateIdback to summary
private final long isolateId
isolatesback to summary
private static final Map<Long, NativeIsolate> isolates
NULLback to summary
private static final long NULL
stateback to summary
private volatile NativeIsolate.State state
threadsback to summary
private final Collection<NativeIsolateThread> threads
uuidback to summary
private final long uuid
UUIDSback to summary
private static final AtomicInteger UUIDS

Constructor Detail

NativeIsolateback to summary
private NativeIsolate(long isolateId, JNIConfig config)

Method Detail

detachCurrentThreadback to summary
public void detachCurrentThread()
detachThreadback to summary
private synchronized void detachThread(NativeIsolateThread nativeIsolateThread)
doIsolateShutdownback to summary
private boolean doIsolateShutdown()
enterback to summary
public NativeIsolateThread enter()

Enters this NativeIsolate on the current thread.

Exceptions
IllegalStateException:
when this NativeObject is already closed or being closed.
forIsolateIdback to summary
public static NativeIsolate forIsolateId(long isolateId, JNIConfig config)

Creates a NativeIsolate for the isolateId and JNIConfig. This method can be called at most once, preferably right after creating the isolate. Use the get(long) method to get an existing NativeIsolate instance.

Returns:NativeIsolate

the newly created NativeIsolate for the isolateId.

Exceptions
IllegalStateException:
when NativeIsolate for the isolateId already exists.
getback to summary
public static NativeIsolate get(long isolateId)

Gets the NativeIsolate object for the entered isolate with the specified isolate address.

Important Note

Must be used only when the isolate with the specified isolateId is entered.

Parameters
isolateId:long

id of an entered isolate

Returns:NativeIsolate

NativeIsolate object for the entered isolate with the specified isolate address

Exceptions
IllegalStateException:
when NativeIsolate does not exist for the isolateId
getConfigback to summary
public JNIConfig getConfig()

Returns the JNIConfig used by this NativeIsolate.

getIsolateIdback to summary
public long getIsolateId()

Returns the isolate address.

getOrCreateNativeIsolateThreadback to summary
private NativeIsolateThread getOrCreateNativeIsolateThread()
isActiveback to summary
public boolean isActive()

Returns true if the current thread is entered to this NativeIsolate.

isDisposedback to summary
public boolean isDisposed()
lastLeaveback to summary
pack-priv void lastLeave()
registerNativeThreadback to summary
public void registerNativeThread(long isolateThreadId)

Binds a native image thread to this isolate. When a thread created in the native image enters for the first time to the host, it must be registered to the NativeIsolate as a native thread.

Parameters
isolateThreadId:long

the isolate thread to bind.

shutdownback to summary
public boolean shutdown()

Requests an isolate shutdown. If there is no host thread entered into this NativeIsolate the isolate is closed and the isolate heap is freed. If this NativeIsolate has active threads the isolate is freed by the last leaving thread.

throwClosedExceptionback to summary
pack-priv RuntimeException throwClosedException()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryEnterback to summary
public NativeIsolateThread tryEnter()

Tries to enter this NativeIsolate on the current thread.

Returns:NativeIsolateThread

NativeIsolateThread on success or null when this NativeIsolate is closed or being closed.

See Also
enter()
org.graalvm.nativebridge back to summary

private final Enum NativeIsolate.State

extends Enum<NativeIsolate.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final NativeIsolate.State
public static final NativeIsolate.State
public static final NativeIsolate.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public static NativeIsolate.State
public static NativeIsolate.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ACTIVEback to summary
public static final NativeIsolate.State ACTIVE
DISPOSEDback to summary
public static final NativeIsolate.State DISPOSED
DISPOSINGback to summary
public static final NativeIsolate.State DISPOSING

Constructor Detail

Stateback to summary
private State()

Method Detail

isValidback to summary
pack-priv boolean isValid()
valueOfback to summary
public static NativeIsolate.State valueOf(String name)
valuesback to summary
public static NativeIsolate.State[] values()