ffi: ensure failure to find functions don't produce null pointer exceptions

This commit is contained in:
Alex Zenla 2023-09-12 01:40:15 -04:00
parent a9e3e8a69a
commit ca111f8e4b
Signed by: alex
GPG Key ID: C0780728420EBFE5

View File

@ -10,6 +10,7 @@ class JnaNativeProvider : NativeProvider {
override fun provideNativeFunction(definition: String, arguments: List<ArgumentSpec>): CallableFunction {
val functionDefinition = FfiFunctionDefinition.parse(definition)
val function = Function.getFunction(functionDefinition.library, functionDefinition.function)
?: throw RuntimeException("Failed to find function ${functionDefinition.function} in library ${functionDefinition.library}")
return CallableFunction { functionArgs ->
val ffiArgs = mutableListOf<Any?>()
for ((index, spec) in arguments.withIndex()) {