Skip to content

Native Image C API breakage on Windows #286

@sgammon

Description

@sgammon

When using Mordant's C API interface on Windows, here, some usages cause breakages on newer versions of the Native Image compiler.

My version of Native Image is:

native-image 25.0.1 2025-10-21
GraalVM Runtime Environment Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01)
Substrate VM Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS, serial gc, compressed references)

Failures of this sort look like:

Error: Expected Object but got Word for call argument in dev.elide.core.term.terminal.terminalinterface.nativeimage.TerminalInterfaceNativeImageWindows.readRawEvent(TerminalInterface.nativeimage.windows.kt:205). One possible cause for this error is when word values are passed into lambdas as parameters or from variables in an enclosing scope, which is not supported, but can be solved by instead using explicit classes (including anonymous classes).
Error: Expected Object but got Word for call argument in dev.elide.core.term.terminal.terminalinterface.nativeimage.TerminalInterfaceNativeImageWindows.readRawEvent(TerminalInterface.nativeimage.windows.kt:205). One possible cause for this error is when word values are passed into lambdas as parameters or from variables in an enclosing scope, which is not supported, but can be solved by instead using explicit classes (including anonymous classes).
Internal exception: com.oracle.svm.core.util.UserError$UserException: Expected Object but got Word for call argument in dev.elide.core.term.terminal.terminalinterface.nativeimage.TerminalInterfaceNativeImageWindows.readRawEvent(TerminalInterface.nativeimage.windows.kt:205). One possible cause for this error is when word values are passed into lambdas as parameters or from variables in an enclosing scope, which is not supported, but can be solved by instead using explicit classes (including anonymous classes).
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:54)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.checkWordType(SharedGraphBuilderPhase.java:1140)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.createMethodCallTarget(SharedGraphBuilderPhase.java:974)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.createMethodCallTarget(BytecodeParser.java:2903)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.createNonInlinedInvoke(BytecodeParser.java:2288)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.appendInvoke(BytecodeParser.java:2187)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1893)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1874)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5884)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3845)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.iterateBytecodesForBlock(SharedGraphBuilderPhase.java:1269)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3805)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3652)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.build(BytecodeParser.java:1193)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.build(SharedGraphBuilderPhase.java:245)
        at jdk.graal.compiler/jdk.graal.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1076)
        at jdk.graal.compiler/jdk.graal.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:103)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:175)
        at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.run(Phase.java:49)
        at jdk.graal.compiler/jdk.graal.compiler.phases.BasePhase.apply(BasePhase.java:468)
        at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:42)
        at jdk.graal.compiler/jdk.graal.compiler.phases.Phase.apply(Phase.java:38)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions