Class NativeIsolate

java.lang.Object
org.graalvm.nativebridge.NativeIsolate

public final class NativeIsolate extends Object
Represents a single native image isolate. All NativeObjects have a NativeIsolate context.
  • 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 the NativeIsolate as a native thread.
      Parameters:
      isolateThreadId - the isolate thread to bind.
    • enter

      public NativeIsolateThread enter()
      Enters this NativeIsolate on the current thread.
      Throws:
      IllegalStateException - when this NativeObject is already closed or being closed.
    • tryEnter

      public NativeIsolateThread tryEnter()
      Tries to enter this NativeIsolate on the current thread.
      Returns:
      NativeIsolateThread on success or null when this NativeIsolate is closed or being closed.
      See Also:
    • isActive

      public boolean isActive()
      Returns true if the current thread is entered to this NativeIsolate.
    • shutdown

      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.
    • getIsolateId

      public long getIsolateId()
      Returns the isolate address.
    • getConfig

      public JNIConfig getConfig()
      Returns the JNIConfig used by this NativeIsolate.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • get

      public static NativeIsolate get(long isolateId)
      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 - when NativeIsolate does not exist for the isolateId
    • forIsolateId

      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:
      the newly created NativeIsolate for the isolateId.
      Throws:
      IllegalStateException - when NativeIsolate for the isolateId already exists.
    • isDisposed

      public boolean isDisposed()
    • detachCurrentThread

      public void detachCurrentThread()