RFR: 8322166: Files.isReadable/isWritable/isExecutable expensive when file does not exist

Chen Liang liach at openjdk.org
Sun Dec 17 06:43:39 UTC 2023


On Fri, 15 Dec 2023 22:49:33 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Add `isReadable`, `isWritable`, and `isExecutable` methods to `AbstractFileSystemProvider` and overrides to `UnixFileSystemProvider` and use these in the respective `Files` methods when the provider is an `AbstractFileSystemProvider`.

src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 365:

> 363:         UnixPath file = UnixPath.toUnixPath(path);
> 364:         file.checkRead();
> 365:         return access(file, R_OK) == 0 ? true : false;

Just curious, why do we use redundant `? true : false` for a boolean value? Such a pattern did not exist in this file before this patch.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17133#discussion_r1429037705


More information about the nio-dev mailing list