RFR: 6245663: (spec) File.renameTo(File) changes the file-system object, not the File instance [v2]

Brian Burkhalter bpb at openjdk.java.net
Thu Feb 18 17:36:39 UTC 2021


On Thu, 18 Feb 2021 16:59:54 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Like so?
>> --- a/src/java.base/share/classes/java/io/File.java
>> +++ b/src/java.base/share/classes/java/io/File.java
>> @@ -1376,7 +1376,9 @@ public class File
>>       * file from one filesystem to another, it might not be atomic, and it
>>       * might not succeed if a file with the destination abstract pathname
>>       * already exists.  The return value should always be checked to make sure
>> -     * that the rename operation was successful.
>> +     * that the rename operation was successful.  As instances of {@code File}
>> +     * are immutable, this File object is not changed to name the destination
>> +     * file or directory.
>>       *
>>       * <p> Note that the {@link java.nio.file.Files} class defines the {@link
>>       * java.nio.file.Files#move move} method to move or rename a file in a
>
> yes, I think that works.

[CSR](https://bugs.openjdk.java.net/browse/JDK-8261935) also so updated.

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

PR: https://git.openjdk.java.net/jdk/pull/2618


More information about the core-libs-dev mailing list