Deduplicating code in BsdUserDefinedFileAttributeView and LinuxUserDefinedFileAttributeView

Sebastian Stenzel sebastian.stenzel at gmail.com
Tue Feb 2 10:02:34 UTC 2021


> On 2. Feb 2021, at 10:21, Sebastian Stenzel <sebastian.stenzel at gmail.com> wrote:
> 
> 
>> On 25. Jan 2021, at 15:00, Alan Bateman <Alan.Bateman at oracle.com <mailto:Alan.Bateman at oracle.com>> wrote:
>> 
>> On 25/01/2021 08:30, Sebastian Stenzel wrote:
>>> 
>>> I guess the pattern here is to assign the `my_methodhandle` to whatever applies during init(), as it is done e.g. for `my_futimens_func`? May I ask why this is done via dlsym()? Since the code is inside an #ifdef directive, so the compiler can't reach it if not applicable, can't I just assign my_futimens_func = futimens?
>>> 
>>> Am I right that we're dealing with four platforms (Linux, Aix, BSD and macOS, the latter being a "special" BSD), that can be distinguished via #ifdef using one of these:
>>> 
>>> ```
>>> __linux__
>>> _AIX
>>> _ALLBSD_SOURCE
>>> MACOSX
>>> ```
>>> 
>>> What about `#ifdef __APPLE__`? I can see this used in various other places.
>>> 
>>> If `_ALLBSD_SOURCE` is supposed to include all BSD flavours, can I simplify this:
>>> 
>>> ```
>>> #if defined(__linux__) || defined(_AIX)
>>> #include <string.h>
>>> #endif
>>> 
>>> #ifdef _ALLBSD_SOURCE
>>> #include <string.h>
>>> ...
>>> #endif
>>> ```
>>> 
>>> to this:
>>> 
>>> ```
>>> #include <string.h>
>>> ```
>>> 
>>> ?
>> 
>> The xxx_func setup in the LinuxNativeDispatcher_init date when from when the xattr functions weren't in the include files used at build-time. A potential first step is to include <attr/xattr.h> and get that change bedded in.
>> 
>> The _ALLBSD_SOURCE vs. MACOSX vs. ... is unfortunate and stems from how the macOS port came into JDK 7u4.  No objection to use _ALLBSD_SOURCE.
>> 
>> -Alan
> 
> So far there is no issue on the bug tracker for this task, is it? If I understand the contribution guideline correctly, PRs without issues will get rejected. Since I have no write access to the bug tracker, shall I submit it via bugreport.java.com <http://bugreport.java.com/>?

Bonus question: May I change `capabilities` to long? https://github.com/openjdk/jdk/blob/jdk-17+7/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java#L569-L574 <https://github.com/openjdk/jdk/blob/jdk-17+7/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java#L569-L574>
I'd like to add `SUPPORTS_XATTR`, but I guess `1 << 32` won't fit into an int.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20210202/7d8269a5/attachment.htm>


More information about the nio-dev mailing list