-
Sub-task
-
Resolution: Delivered
-
P4
-
25
-
windows
`File.delete` is changed on Windows so that it now fails and returns `false` for regular files when the DOS read-only attribute is set. Prior to JDK 25, `File.delete` deleted read-only files by removing this DOS attribute before attempting to delete. As removing the attribute and deleting the file do not comprise a single atomic operation, this could result in the file still existing but with modified attributes if the deletion were to fail. Applications that depend on long standing behavior should be changed to clear the file attributes prior to deletion.
As part of the change, a system property has been introduced to restore long standing behavior. Running with `-Djdk.io.File.allowDeleteReadOnlyFiles=true` will restore old behavior so that `File.delete` removes the DOS read-only attribute before attempting to delete the file.
As part of the change, a system property has been introduced to restore long standing behavior. Running with `-Djdk.io.File.allowDeleteReadOnlyFiles=true` will restore old behavior so that `File.delete` removes the DOS read-only attribute before attempting to delete the file.