Bindings crash on Windows where they would not before

jextract at xpple.dev jextract at xpple.dev
Fri Mar 28 21:53:03 UTC 2025


Hello,

Firstly, thanks to the people behind this tool, I really like it. I have 
used it for both C and Rust libraries with great success.

Unfortunately though, it seems commit [1] from PR [2] and relevant issue 
[3] caused bindings to generate that crash on Windows, where they before 
would not. I let GitHub Actions generate my bindings on an Ubuntu 
runner, where the size of the type `long` is `64` bits. On Windows 
however, the size of this type is `32` bits (thank Microsoft for 
that...). This means that on Windows, the bindings crash with the 
message `java.lang.ClassCastException: class 
jdk.internal.foreign.layout.ValueLayouts$OfIntImpl cannot be cast to 
class java.lang.foreign.ValueLayout$OfLong 
(jdk.internal.foreign.layout.ValueLayouts$OfIntImpl and 
java.lang.foreign.ValueLayout$OfLong are in module java.base of loader 
'bootstrap')`. Before the `long` type was of _fixed_ size (regardless of 
the actual size), preventing a mismatch. While I know platform agnosticy 
is not a specific goal of jextract, this seems easy enough to provide a 
fix for. For instance the platform check could be done at runtime.

In the meantime, what would your recommended fix be for my issue?

Kind regards,


Frederik van der Els

[1] 
https://github.com/openjdk/jextract/commit/1c614f31fac9e6309e8d3498a128ac9484348c85
[2] https://github.com/openjdk/jextract/pull/269
[3] https://bugs.openjdk.org/browse/CODETOOLS-7903923


More information about the jextract-dev mailing list