Class NativeIsolate
java.lang.Object
org.graalvm.nativebridge.NativeIsolate
Represents a single native image isolate. All
NativeObjects have a NativeIsolate
context.-
Method Summary
Modifier and TypeMethodDescriptionvoidenter()Enters thisNativeIsolateon the current thread.static NativeIsolateforIsolateId(long isolateId, JNIConfig config) static NativeIsolateget(long isolateId) Gets the NativeIsolate object for the entered isolate with the specified isolate address.Returns theJNIConfigused by thisNativeIsolate.longReturns the isolate address.booleanisActive()Returns true if the current thread is entered to thisNativeIsolate.booleanvoidregisterNativeThread(long isolateThreadId) Binds a native image thread to this isolate.booleanshutdown()Requests an isolate shutdown.toString()tryEnter()Tries to enter thisNativeIsolateon the current thread.
-
Method Details
-
registerNativeThread
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 theNativeIsolateas a native thread.- Parameters:
isolateThreadId- the isolate thread to bind.
-
enter
Enters thisNativeIsolateon the current thread.- Throws:
IllegalStateException- when thisNativeObjectis already closed or being closed.
-
tryEnter
Tries to enter thisNativeIsolateon the current thread.- Returns:
NativeIsolateThreadon success ornullwhen thisNativeIsolateis closed or being closed.- See Also:
-
isActive
public boolean isActive()Returns true if the current thread is entered to thisNativeIsolate. -
shutdown
public boolean shutdown()Requests an isolate shutdown. If there is no host thread entered into thisNativeIsolatethe isolate is closed and the isolate heap is freed. If thisNativeIsolatehas active threads the isolate is freed by the last leaving thread. -
getIsolateId
public long getIsolateId()Returns the isolate address. -
getConfig
Returns theJNIConfigused by thisNativeIsolate. -
toString
-
get
Gets the NativeIsolate object for the entered isolate with the specified isolate address. IMPORTANT: Must be used only when the isolate with the specified isolateId is entered.- Parameters:
isolateId- id of an entered isolate- Returns:
- NativeIsolate object for the entered isolate with the specified isolate address
- Throws:
IllegalStateException- whenNativeIsolatedoes not exist for theisolateId
-
forIsolateId
Creates aNativeIsolatefor theisolateIdandJNIConfig. This method can be called at most once, preferably right after creating the isolate. Use theget(long)method to get an existingNativeIsolateinstance.- Returns:
- the newly created
NativeIsolatefor theisolateId. - Throws:
IllegalStateException- whenNativeIsolatefor theisolateIdalready exists.
-
isDisposed
public boolean isDisposed() -
detachCurrentThread
public void detachCurrentThread()
-