RFR: 8365807: (fs) Two-arg UnixFileAttributes.getIfExists should not use exception for control flow [v3]

Alan Bateman alanb at openjdk.org
Tue Aug 26 07:09:42 UTC 2025


On Mon, 25 Aug 2025 19:44:13 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> In the Unix implementation of `sun.nio.fs`, change
>> 
>> 1. `UnixFileAttributes.getIfExists(UnixPath,boolean)` to use the system call success status and `errno` for control flow; and
>> 2. `UnixFileAttributes.getIfExists(UnixPath)` to simply return `UnixFileAttributes.getIfExists(UnixPath,true)`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8365807: Reinstate stat2; add fstatat2 returning errno

I think this looks good and avoids the hazards from the early iterations.

src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java line 87:

> 85:     // Returns null if the file does not exist.
> 86:     static UnixFileAttributes getIfExists(UnixPath path) throws UnixException
> 87:     {

Minor style nit, the "{" can move to the previous line.

src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java line 292:

> 290:      */
> 291:     static void  fstatat(int dfd, UnixPath path, int flag, UnixFileAttributes attrs)
> 292:         throws UnixException

Minor style nit, we've ended with two spaces between void and fstatat.

src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java line 306:

> 304:     // Variant of fstatat() returning errno instead of throwing UnixException
> 305:     static int fstatat2(int dfd, UnixPath path, int flag, UnixFileAttributes attrs)
> 306:     {

Minor style nit, the "{" can move to the previous line.

-------------

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26889#pullrequestreview-3154237578
PR Review Comment: https://git.openjdk.org/jdk/pull/26889#discussion_r2300001804
PR Review Comment: https://git.openjdk.org/jdk/pull/26889#discussion_r2300003378
PR Review Comment: https://git.openjdk.org/jdk/pull/26889#discussion_r2300001649


More information about the nio-dev mailing list