Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use with GraalVM Native Image #164

Open
xhyrom opened this issue Feb 27, 2025 · 0 comments
Open

Unable to use with GraalVM Native Image #164

xhyrom opened this issue Feb 27, 2025 · 0 comments

Comments

@xhyrom
Copy link

xhyrom commented Feb 27, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant