Skip to content

Native Image: JNIRegistrationSupport.makeShimLibrary fails on Windows with ForeignAPISupport enabled #13948

Description

@tristantarrant

Describe the issue

When building a native image on Windows with -H:+ForeignAPISupport and --enable-native-access=ALL-UNNAMED, the build fails during the afterImageWrite phase with:

com.oracle.svm.shared.util.VMError$HostedError: should not reach here: unexpected input could not be handled: 2
    at com.oracle.svm.shared.util.VMError.shouldNotReachHereUnexpectedInput(VMError.java:140)
    at com.oracle.svm.hosted.jdk.JNIRegistrationSupport.makeShimLibrary(JNIRegistrationSupport.java:510)
    at com.oracle.svm.hosted.jdk.JNIRegistrationSupport.makeShimLibraries(JNIRegistrationSupport.java:456)
    at com.oracle.svm.hosted.jdk.JNIRegistrationSupport.afterImageWrite(JNIRegistrationSupport.java:306)

The image compilation itself completes successfully (all 8 stages), but the shim library creation fails. The build works fine on Linux and macOS.

Steps to reproduce

  1. Use Oracle GraalVM 25.1.3 on Windows
  2. Build a native image with these flags:
    • --enable-native-access=ALL-UNNAMED
    • -H:+ForeignAPISupport
  3. Include foreign downcall registrations in reachability-metadata.json, e.g.:
{
  "foreign": {
    "downcalls": [
      {"returnType": "jlong", "parameterTypes": ["jlong"]},
      {"returnType": "jlong", "parameterTypes": ["jlong", "jlong"]},
      {"returnType": "void", "parameterTypes": ["jlong"]}
    ]
  }
}

GraalVM version and target

  • GraalVM version: Oracle GraalVM 25.1.3+9.1 (Java 25.0.3+9-LTS)
  • OS: Windows (GitHub Actions windows-2022 runner)
  • C compiler: cl.exe (microsoft, x64, 19.44.35228)
  • Architecture: x86-64

More details

The error occurs in the Windows-specific shim library generation code path. The makeShimLibrary method encounters an unexpected input value of 2 that it cannot handle, suggesting a missing case in a switch or conditional for a library type introduced by the foreign function support.

Full error report: https://github.com/infinispan/infinispan/actions/runs/29005045857/job/86074536310?pr=17766

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions