Skip to content

Fix variable-size type mappings in mac SystemB and XAttr#1724

Merged
dbwiddis merged 1 commit into
java-native-access:masterfrom
dbwiddis:fix-variable-size-mappings
May 12, 2026
Merged

Fix variable-size type mappings in mac SystemB and XAttr#1724
dbwiddis merged 1 commit into
java-native-access:masterfrom
dbwiddis:fix-variable-size-mappings

Conversation

@dbwiddis
Copy link
Copy Markdown
Contributor

Fix incorrect use of long/LongByReference for pointer-sized native types in macOS bindings.

SystemB.host_page_size: The vm_size_t * parameter was mapped as LongByReference (always 64-bit). Added correct NativeLongByReference overload; deprecated the old signature.

XAttr.getxattr/setxattr/listxattr: The size_t parameters and ssize_t return values were mapped as long (always 64-bit). Added correct NativeLong overloads; deprecated the old signatures. Updated XAttrUtil to use the new methods.

These types are pointer-sized (unsigned long in C) and should be 4 bytes on 32-bit and 8 bytes on 64-bit. While macOS is effectively 64-bit-only today, JNA still supports 32-bit macOS and the mappings should be correct.

@dbwiddis dbwiddis force-pushed the fix-variable-size-mappings branch from 8c45049 to 4ab4109 Compare May 12, 2026 03:51
Comment thread contrib/platform/src/com/sun/jna/platform/mac/XAttr.java Outdated
Comment thread contrib/platform/src/com/sun/jna/platform/mac/SystemB.java
@dbwiddis dbwiddis force-pushed the fix-variable-size-mappings branch from 4ab4109 to 4450bf9 Compare May 12, 2026 18:27
host_page_size used LongByReference for vm_size_t* which is
pointer-sized. Add correct NativeLongByReference overload and
deprecate the old one.

XAttr getxattr/setxattr/listxattr used long for size_t/ssize_t
parameters and return values. Add correct NativeLong overloads
and deprecate the old ones. Update XAttrUtil to use the new
methods.
@dbwiddis dbwiddis force-pushed the fix-variable-size-mappings branch from 4450bf9 to 95d793e Compare May 12, 2026 18:30
Copy link
Copy Markdown
Member

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dbwiddis dbwiddis merged commit 7897cc7 into java-native-access:master May 12, 2026
12 checks passed
@dbwiddis dbwiddis deleted the fix-variable-size-mappings branch May 12, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants