Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355954 File.delete removes read-only files (win)
  3. JDK-8356195

Release Note: java.io.File.delete no longer deletes read-only files on Windows

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Delivered
    • Icon: P4 P4
    • 25
    • 25
    • core-libs
    • 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.

            bpb Brian Burkhalter
            bpb Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: