Class NativeLibraryLoader
java.lang.Object
ai.tegmentum.wasmtime4j.panama.NativeLibraryLoader
Native library loader for Panama FFI implementation.
This class handles native library loading and function discovery for the wasmtime4j-panama
module. It uses the shared NativeLibraryUtils for platform detection and library loading,
while providing Panama-specific functionality for function symbol lookup and resource management
using Arena-based cleanup.
-
Method Summary
Modifier and TypeMethodDescriptionvoidClears the method handle cache.voidclose()Closes the library and cleans up resources.Gets diagnostic information about the Panama library loader.static NativeLibraryLoaderGets the singleton instance of the native library loader.Gets the Arena used for library resource management.ai.tegmentum.wasmtime4j.nativeloader.NativeLibraryUtils.LibraryLoadInfoGets information about the library loading attempt.Gets the loading error if library loading failed.Gets the SymbolLookup for the loaded native library.booleanisLoaded()Checks if the native library is loaded and available.lookupFunction(String functionName, FunctionDescriptor descriptor) Looks up a function symbol and returns a MethodHandle.
-
Method Details
-
getInstance
Gets the singleton instance of the native library loader.- Returns:
- the singleton instance
- Throws:
IllegalStateException- if library loading failed
-
isLoaded
public boolean isLoaded()Checks if the native library is loaded and available.- Returns:
- true if loaded successfully, false otherwise
-
getLoadingError
-
getLoadInfo
public ai.tegmentum.wasmtime4j.nativeloader.NativeLibraryUtils.LibraryLoadInfo getLoadInfo()Gets information about the library loading attempt.- Returns:
- the load info
-
lookupFunction
Looks up a function symbol and returns a MethodHandle.- Parameters:
functionName- the name of the function to look updescriptor- the function descriptor defining signature- Returns:
- optional containing the MethodHandle, or empty if not found
-
getSymbolLookup
Gets the SymbolLookup for the loaded native library.- Returns:
- the symbol lookup
- Throws:
IllegalStateException- if the library is not loaded
-
getLibraryArena
Gets the Arena used for library resource management.- Returns:
- the library arena
-
clearMethodHandleCache
public void clearMethodHandleCache()Clears the method handle cache. -
close
public void close()Closes the library and cleans up resources. This should only be called during JVM shutdown. -
getDiagnosticInfo
Gets diagnostic information about the Panama library loader.- Returns:
- diagnostic information string
-