Class PanamaExceptionHandler

java.lang.Object
ai.tegmentum.wasmtime4j.panama.experimental.PanamaExceptionHandler
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.experimental.ExceptionHandler, AutoCloseable

public final class PanamaExceptionHandler extends Object implements ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
Panama implementation of WebAssembly exception handling.

This class provides Panama Foreign Function API bindings for WebAssembly exception handling, integrating with the native Rust implementation while ensuring proper resource management and defensive programming practices.

Since:
1.0.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler

    ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig, ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag, ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.HandlingResult
  • Method Summary

    Modifier and Type
    Method
    Description
    captureStackTrace(long tagHandle)
     
    void
     
    Creates a new Panama exception handler with default configuration.
    create(ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig config)
    Creates a new Panama exception handler with the specified configuration.
    create(ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig config, String handlerName)
    Creates a new Panama exception handler with the specified configuration and name.
    ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag
    createExceptionTag(String name, List<ai.tegmentum.wasmtime4j.WasmValueType> parameterTypes)
     
    ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig
     
    Optional<ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag>
     
     
    Gets the native memory segment handle.
    ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag
    getTagByHandle(long tagHandle)
    Gets a cached exception tag by handle.
    ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.HandlingResult
    handle(Throwable exception)
     
    boolean
    Checks if this handler is closed.
    boolean
     
    List<ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag>
     
    boolean
    performUnwinding(int currentDepth)
     
    void
    setEnabled(boolean enabled)
    Enables or disables this exception handler.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static PanamaExceptionHandler create()
      Creates a new Panama exception handler with default configuration.
      Returns:
      a new exception handler
    • create

      public static PanamaExceptionHandler create(ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig config)
      Creates a new Panama exception handler with the specified configuration.
      Parameters:
      config - the exception handling configuration
      Returns:
      a new exception handler
      Throws:
      NullPointerException - if config is null
    • create

      public static PanamaExceptionHandler create(ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig config, String handlerName)
      Creates a new Panama exception handler with the specified configuration and name.
      Parameters:
      config - the exception handling configuration
      handlerName - the handler name
      Returns:
      a new exception handler
      Throws:
      NullPointerException - if config or handlerName is null
    • handle

      public ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.HandlingResult handle(Throwable exception)
      Specified by:
      handle in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • getHandlerName

      public String getHandlerName()
      Specified by:
      getHandlerName in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables or disables this exception handler.
      Parameters:
      enabled - true to enable, false to disable
    • createExceptionTag

      public ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag createExceptionTag(String name, List<ai.tegmentum.wasmtime4j.WasmValueType> parameterTypes)
      Specified by:
      createExceptionTag in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • getExceptionTag

      public Optional<ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag> getExceptionTag(String name)
      Specified by:
      getExceptionTag in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • listExceptionTags

      public List<ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag> listExceptionTags()
      Specified by:
      listExceptionTags in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • captureStackTrace

      public String captureStackTrace(long tagHandle)
      Specified by:
      captureStackTrace in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • performUnwinding

      public boolean performUnwinding(int currentDepth)
      Specified by:
      performUnwinding in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • getConfig

      public ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionHandlingConfig getConfig()
      Specified by:
      getConfig in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.experimental.ExceptionHandler
    • getTagByHandle

      public ai.tegmentum.wasmtime4j.experimental.ExceptionHandler.ExceptionTag getTagByHandle(long tagHandle)
      Gets a cached exception tag by handle.
      Parameters:
      tagHandle - the tag handle
      Returns:
      the exception tag, or null if not found
    • getNativeHandle

      public MemorySegment getNativeHandle()
      Gets the native memory segment handle.
      Returns:
      the native handle
    • isClosed

      public boolean isClosed()
      Checks if this handler is closed.
      Returns:
      true if closed