<div dir="ltr"><div dir="ltr">Hi Maurizio<div><br></div><div>I have tried to upgrade the JavaDoesUSB library (<a href="https://github.com/manuelbl/JavaDoesUSB" target="_blank">https://github.com/manuelbl/JavaDoesUSB</a>) from JDK 21 to 22, and it was very frustrating. It failed on macOS, Windows nor Linux. And the problem is jextract.</div><div><br></div><div>(The header files I'm trying the process are operating system header files.)</div><div><br></div><div><br></div><div>On macOS, it always crashes:</div><div><br></div><div>FATAL: Unexpected exception java.lang.NullPointerException: Cannot invoke "org.openjdk.jextract.Declaration$Constant.name()" because "<parameter2>" is null occurred<br></div><div><br></div><div>I've tried different branches (master, panama, jdk22) and the pre-built binaries. They all behave the same except the error message is sometimes shorter and starts at "Cannot invoke..."</div><div><br></div><div>The full commands can be found here (remove "--source"): <a href="https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/macos/gen_macos.sh">https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/macos/gen_macos.sh</a></div><div><br></div><div><br></div><div>On Linux, jextract worked partially. But for several files, it refused to generate anything or generated code that didn't compile:</div><div><br></div><div>/usr/include/fcntl.h:</div><div>ERROR: stat depends on timespec which has been excluded<br>ERROR: stat depends on timespec which has been excluded<br>ERROR: stat depends on timespec which has been excluded<br></div><div><br></div><div>/usr/include/libudev.h:</div><div>ERROR: __pthread_list_t depends on __pthread_internal_list which has been excluded<br>ERROR: __pthread_slist_t depends on __pthread_internal_slist which has been excluded<br>ERROR: __pthread_mutex_s depends on __pthread_internal_list which has been excluded<br>WARNING: Skipping va_list (type <error: struct __va_list_tag> is not supported)<br>WARNING: Skipping __gnuc_va_list (type <error: struct __va_list_tag> is not supported)<br>WARNING: Skipping udev (type Declared(udev) is not supported)<br>WARNING: Skipping udev_list_entry (type Declared(udev_list_entry) is not supported)<br>WARNING: Skipping udev_device (type Declared(udev_device) is not supported)<br>WARNING: Skipping udev_monitor (type Declared(udev_monitor) is not supported)<br>WARNING: Skipping udev_enumerate (type Declared(udev_enumerate) is not supported)<br>WARNING: Skipping udev_queue (type Declared(udev_queue) is not supported)<br>WARNING: Skipping udev_hwdb (type Declared(udev_hwdb) is not supported)<br></div><div><br></div><div>sys/epoll.h:</div><div>ERROR: __pthread_list_t depends on __pthread_internal_list which has been excluded<br>ERROR: __pthread_slist_t depends on __pthread_internal_slist which has been excluded<br>ERROR: __pthread_mutex_s depends on __pthread_internal_list which has been excluded<br>ERROR: epoll_data_t depends on epoll_data which has been excluded<br>ERROR: epoll_event depends on epoll_data which has been excluded<br></div><div><br></div><div>/usr/include/linux/usbdevice_fs.h:<br></div><div>The code generated for the structusbdevfs_urb does not compile (it refers to a type usbdevfs_iso_packet_desc, which is missing).</div><div><br></div><div>The full commands for jextract can be found here. I've only removed "--source" as it is no longer needed.</div><div><a href="https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/linux/gen_linux.sh">https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/linux/gen_linux.sh</a><br></div><div><br></div><div>All these files could successfully be processed with jextract 21.</div><div><br></div><div>I don't understand the error message. What does "xxx depends on yyy which has been excluded" mean? Have I used it incorrectly? The error message mostly mentions types (and possibly functions) that I don't use, neither directly nor indirectly.</div><div><br></div><div>And why are udev, udev_list_entry, udev_device etc. skipped? They used to work with jextract 21.</div><div><br></div><div><br></div><div>On Windows, it completely failed as well. jextract outputs more than 5000 lines of errors and warnings. Here is just a random selection:</div><div><br></div><div>ERROR: mbstate_t depends on _Mbstatet which has been excluded<br></div><div>ERROR: LIST_ENTRY depends on _LIST_ENTRY which has been excluded<br></div><div>ERROR:  depends on _M128A which has been excluded<br></div><div>ERROR: WIN32_FIND_STREAM_DATA depends on _WIN32_FIND_STREAM_DATA which has been excluded<br></div><div>ERROR: tagEXTLOGFONTW depends on tagLOGFONTW which has been excluded<br></div><div>ERROR: MULTIKEYHELPW depends on tagMULTIKEYHELPW which has been excluded<br></div><div>WARNING: Skipping MEM_EXTENDED_PARAMETER.Reserved (bitfields are not supported)<br></div><div>WARNING: Skipping Flags.Reserved (bitfields are not supported)<br></div><div><br></div><div>The full command can be found here (remove "--source"): <a href="https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/windows/gen_win.cmd">https://github.com/manuelbl/JavaDoesUSB/blob/main/java-does-usb/jextract/windows/gen_win.cmd</a></div><div><br></div><div><br></div><div><br></div><div>The REAMDE on <a href="https://github.com/openjdk/jextract">https://github.com/openjdk/jextract</a> could also profit from an update:</div><div><br></div><div>The command line "$ sh ./gradlew -Pjdk21_home=<jdk21_home_dir> ..." sent me on search for the branch with the JDK 22 code. But it's just the README that's outdated.</div><div><br></div><div>And the instruction "Run the Gradle build with a Java version appropriate for the Gradle version. For example, Gradle 7.5.1 supports JDK 21." sent me down another rabbit hole. I have the latest Gradle version installed, which nicely runs with JDK 21. But it failed anyway. Turns out that the installed gradle is irrelevant but the gradle wrapper relevant (see command line above). And the gradle wrapper is at version 7.3.3. So there is nothing to choose really. You must use JDK 17 (or even earlier). It has never worked with JDK 21.</div><div><br></div><div><br></div><div>I would appreciate some feedback. Are these bugs? Or has jextract become so much more restrictive?</div><div><br></div><div>Regards</div><div>Manuel</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Fr., 16. Feb. 2024 um 16:50 Uhr schrieb Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank">maurizio.cimadamore@oracle.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi,<br>
with JDK 22 near us, we have spent some quality time with jextract, to <br>
make sure the code it generates is as good as it can be ahead of the <br>
finalizaton of the FFM API. This resulted in several changes, both in <br>
the implementation (so, invisible to jextract users) and in the <br>
generated code, as we cleaned up the translation strategy to better <br>
adhere with the core principles behind the jextract tool. These changes <br>
are captured in details in this document:<br>
<br>
<a href="https://cr.openjdk.org/~mcimadamore/panama/jextract_changes.html" rel="noreferrer" target="_blank">https://cr.openjdk.org/~mcimadamore/panama/jextract_changes.html</a><br>
<br>
It might be a good time to take the latest jextract for a spin (using <br>
your favourite C library!) and report back, in case we missed anything. <br>
You can find the latest sources in this branch:<br>
<br>
<a href="https://github.com/openjdk/jextract/tree/panama" rel="noreferrer" target="_blank">https://github.com/openjdk/jextract/tree/panama</a><br>
<br>
Binary snapshots of this newer version are also available here (note <br>
that MacOS/Arm64 builds is also supported now):<br>
<br>
<a href="https://jdk.java.net/jextract/" rel="noreferrer" target="_blank">https://jdk.java.net/jextract/</a><br>
<br>
Cheers<br>
Maurizio<br>
<br>
</blockquote></div>
</div>