jextract for operating system API
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Sep 5 15:45:58 UTC 2022
On 23/08/2022 21:31, Manuel Bleichenbacher wrote:
> (1) The generated class _USB_NODE_CONNECTION_INFORMATION_EX cannot be
> instanciated. The constructor throws the exception:
> java.lang.UnsupportedOperationException: Invalid alignment
> requirements for layout s16(DeviceAddress)
>
> This struct (like many USB descriptors) is packed with 16-bit integer
> values on odd offsets. jextract insists on creating a layout with
> strict alignment rules. So the generated layout
> net.codecrete.usb.windows.gen.usbioctl._USB_NODE_CONNECTION_INFORMATION_EX#$struct$LAYOUT
> fails, while the manually created layout
> net.codecrete.usb.windows.USBIOCtl#USB_NODE_CONNECTION_INFORMATION_EX$Struct
> works.
Seems like you have ran into this issue:
https://bugs.openjdk.org/browse/JDK-8259832
>
> (2) The struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W isn't usable. In C,
> it looks like this:
>
> typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W {
> DWORD cbSize;
> WCHAR DevicePath[ANYSIZE_ARRAY];
> } SP_DEVICE_INTERFACE_DETAIL_DATA_W, *PSP_DEVICE_INTERFACE_DETAIL_DATA_W;
In general, there's not much that can be done for variable-length arrays
- but perhaps, in the idiomatic case where the array occurs as the last
field of a struct, the allocate methods for the struct could take the
array size and allocate a segment that is big enough. We could also emit
(unsafe) accessors to access elements of the VLA.
Filed an issue to keep track of this:
https://bugs.openjdk.org/browse/CODETOOLS-7903283
Thanks
Maurizio
More information about the jextract-dev
mailing list