RFR: 8367284: (fs) Support current working directory target in SecureDirectoryStream.move
Brian Burkhalter
bpb at openjdk.org
Fri Sep 12 17:01:13 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>
> ...
Hello @jaikiran.
> 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.
The "open directory" is the one which was passed to `Files.newDirectoryStream` to create the `SecureDirectoryStream`. The working directory is as usual the value of the system property "user.dir" and the value obtained by the library function `getcwd`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27178#discussion_r2344916661
More information about the nio-dev
mailing list