RFR: 8295753: (fs) UnixPath::toRealPath does not return correct case when links not followed [v3]

Alan Bateman alanb at openjdk.org
Thu Nov 3 11:50:36 UTC 2022


On Thu, 3 Nov 2022 01:10:05 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> On macOS, ensure that the components of the `Path` returned by `UnixPath::toRealPath` have the case retained by the file system as opposed to that of the representation present in the `UnixPath` instance.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8295753: Clean up UnixPath; rename retentive to preserving

src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 814:

> 812: 
> 813:     @Override
> 814:     @SuppressWarnings("removal")

I assume this can be removed.

src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 876:

> 874:         UnixPath path = fs.rootDirectory();
> 875: 
> 876:         SecurityManager sm = System.getSecurityManager();

I assume this can be removed too.

src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 893:

> 891:             UnixPath elementPath = path.resolve(element);
> 892: 
> 893:             // Derive element key

You might want to re-visit the comments at L890 and 893 and there is no deviation, instead it just gets the file key. The API allows is to be null but the Unix implementation is always non-null.

src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 907:

> 905:             DirectoryStream.Filter<Path> filter = (p) -> { return true; };
> 906:             try (DirectoryStream<Path> entries =
> 907:                 getFileSystem().provider().newDirectoryStream(path, filter)) {

I think the algorithm is correct, just need to fix the strange intend at 907.

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

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


More information about the nio-dev mailing list