Class NativeLibrary
java.lang.Object
org.jetbrains.nativecerts.NativeLibrary
A thin wrapper around
SymbolLookup and Linker for a single native library.
Binding classes (SecurityFramework, CoreFoundationExt, Crypt32Ext, ...) create one
MethodHandle per native function via downcall(String, FunctionDescriptor, Linker.Option...) and expose it as a typed static Java method
named exactly like the native function, so that the code can be read side by side with Apple/Microsoft
documentation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondowncall(String name, FunctionDescriptor descriptor, Linker.Option... options) Creates a downcall handle for an exported function.pointerVariable(String name) Reads the value of an exported pointer-sized global variable, e.g.static RuntimeExceptionConverts aThrowablethrown byMethodHandle.invokeExact(Object...)into an unchecked exception.
-
Constructor Details
-
NativeLibrary
- Parameters:
path- Absolute path of the library or framework binary. The library is loaded once and stays loaded for the lifetime of the JVM (Arena.global()).
-
-
Method Details
-
symbol
- Returns:
- Address of an exported symbol (a function or a global variable).
- Throws:
UnsatisfiedLinkError- if the symbol is not exported by the library
-
pointerVariable
Reads the value of an exported pointer-sized global variable, e.g.kSecClassorkCFBooleanTrue. The symbol itself is the address of the variable; the variable holds the pointer we are interested in. -
downcall
Creates a downcall handle for an exported function. -
rethrow
Converts aThrowablethrown byMethodHandle.invokeExact(Object...)into an unchecked exception. Downcall handles do not throw checked exceptions in practice; this exists only to satisfy the compiler without hiding a real failure.
-