RFR: 8367284: (fs) Support current working directory target in SecureDirectoryStream.move

Alan Bateman alanb at openjdk.org
Fri Sep 12 10:58:21 UTC 2025


On Fri, 12 Sep 2025 10:37:11 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Change `java.nio.file.SecureDirectoryStream.move` so that, instead of throwing a `NullPointerException` if the `targetdir` parameter is `null`, it considers a non-absolute path passed via `targetpath` as being relative to the current working directory.
>
> src/java.base/share/classes/java/nio/file/SecureDirectoryStream.java line 199:
> 
>> 197:      * by the {@code targetdir} parameter, unless {@code targetdir} is
>> 198:      * {@code null}, in which case it is located relative to the current
>> 199:      * working directory. In all cases, if the target file exists then it is
> 
> Hello Brian, This is the first time I'm seeing this interface so I have some very basic questions. Is there a difference between working directory and open directory in context of this interface? The class level javadoc and several other places of this interface use "open directory" as a term to specify the semantics of these methods.
> 
> I'm a bit surprised by this interface in general. It has a type parameter `T` and also these methods work on that type, and `T` can be anything and not just a `java.nio.file.Path` type. But this entire interface appears to be for `Path` based operations:
> 
> 
> public interface SecureDirectoryStream<T>
>     extends DirectoryStream<T>
> ...

The type parameter is because it was design to support file IDs and other ways to address files. These other approaches didn't really materilize so it's only currently used with Path objects. So a somewhat niche API. I think it needs thinking before adding to it. Advanced cases that want to go to *at syscalls can use FFM, they don't need to use this API.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27178#discussion_r2343840958


More information about the nio-dev mailing list