-
Notifications
You must be signed in to change notification settings - Fork 25
Description
It seems the newly released version 0.26.0 does not work on Windows:
java.lang.ExceptionInInitializerError
at io.github.treesitter.jtreesitter.Language.<clinit>(Language.java:19)
at ...
Caused by: 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')
at io.github.treesitter.jtreesitter.internal.TreeSitter$shared.<clinit>(TreeSitter$shared.java:30)
... 4 moreThe problem appears to be that for the release build jtreesitter assumes that the jextract-generated code for Linux also works for all other supported OS (macOS and Windows). However, due to https://bugs.openjdk.org/browse/CODETOOLS-7903923 (see also linked GitHub PR there) at least for Windows that is no longer the case.
Maybe this could be solved with the following patch for the generated TreeSitter$shared.java?
- public static final ValueLayout.OfLong C_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("long");
+ public static final ValueLayout.OfLong C_LONG = C_LONG_LONG;For Linux I think this is correct? For Windows this is technically incorrect but it seems for all function signatures the jextract generated code uses C_LONG_LONG instead of C_LONG on Windows, so effectively this patch here would account for that? Please double-check if possible though.
You can for example modify the CI workflow for testing to upload the jextract-generated code as artifact (as done here).
The reason why the Windows GitHub CI workflow is not failing is probably because it runs jextract itself and therefore generates Windows-compatible code. Maybe it would be better if the CI workflow ran jextract only for Linux, uploaded the results as artifacts and then reused them for all OS, to match the behavior of the release workflow?