RFR: 8283335 : Add exists and readAttributesIfExists methods to FileSystemProvider

Alan Bateman alanb at openjdk.org
Thu Jun 23 10:59:53 UTC 2022


On Wed, 22 Jun 2022 19:05:41 GMT, Lance Andersen <lancea at openjdk.org> wrote:

> Hi,
> 
> Please review the following patch which will:
> 
> - Enhance the java.nio.file.spi.FileSystemProvider abstract class to include the methods
> 
>   - public boolean exists(Path path, LinkOption... options)
>   - public <A extends BasicFileAttributes> A readAttributesIfExists(Path path, Class<A> type, LinkOption... options)
> 
> 
> This change allows for providers to provide optimizations when the file's attributes are not needed.
> 
> Mach5 tiers 1 - 3  run clean with this change
> 
> The CSR may be viewed at [JDK-8283336](https://bugs.openjdk.org/browse/JDK-8283336)
> 
> 
> Best,
> Lance

This should be performance neutral for the default provider and positive for the zip provider. Do we have any micros that could be added?

The end date in the copyright header will need updated a few files, I assume you'll do that before this change is integrated.

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

> 304:                     case WRITE -> w = true;
> 305:                     case EXECUTE -> x = true;
> 306:                     default -> throw new AssertionError("Should not get here");

The switch should be exhaustive so I assume the default case is not required here.

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

PR: https://git.openjdk.org/jdk/pull/9249


More information about the core-libs-dev mailing list