Skip to content

Unable to use with GraalVM Native Image #164

@xhyrom

Description

@xhyrom

When attempting to use jnr/jffi with a GraalVM native image, I encounter an UnsatisfiedLinkError when loading jnr.ffi.provider.jffi.Provider. The issue does not occur when running using JVM. I use this library with https://github.com/lmdbjava/lmdbjava.

Error Message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
    at jnr.ffi.provider.InvalidProvider$1.loadLibrary(InvalidProvider.java:49)
    at jnr.ffi.LibraryLoader.load(LibraryLoader.java:420)
    ...
Caused by: java.lang.UnsatisfiedLinkError: could not get native definition for type `POINTER`, original error message follows: null
    at com.kenai.jffi.Type$Builtin.lookupTypeInfo(Type.java:253)
    ...

GraalVM Proxy and Reflection Configuration:
proxy-config:

[
  {
    "interfaces": [
      "org.lmdbjava.Library$Lmdb",
      "jnr.ffi.provider.LoadedLibrary"
    ]
  }
]

reflection-config:

[
  {
    "name": "jnr.ffi.provider.jffi.Provider",
    "allDeclaredConstructors": true,
    "allDeclaredMethods": true,
    "allDeclaredFields": true
  },
  {
    "name": "jnr.ffi.LibraryLoader",
    "allDeclaredFields": true,
    "allDeclaredMethods": true,
    "allDeclaredConstructors": true
  },
  {
    "name": "jnr.ffi.provider.FFIProvider",
    "allDeclaredFields": true,
    "allDeclaredMethods": true,
    "allDeclaredConstructors": true
  }
]

Resource Configuration:

{
  "resources": {
    "includes": [
      {
        "pattern": ".*\\.(so|dll)"
      }
    ]
  }
}

Steps to Reproduce:

  1. Compile a native image using GraalVM that includes jnr/jffi.
  2. Run the executable.
  3. Observe the UnsatisfiedLinkError.

Expected Behavior:
jnr/jffi should function correctly when compiled into a GraalVM native image, loading native definitions without errors.

Environment:

  • OS: Void Linux
  • Kernel Version: 6.12.16_1
  • GraalVM Version: 23.0.1
  • JNR/JFFI Version: 2.2.17
  • LMDB Java Version: 0.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions