JDK-6728842 : File.setReadOnly does not make a directory read-only (win)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-07-23
  • Updated: 2017-05-16
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u21-revFixed 7 b116Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
File's setReadOnly method [Also setWritable(false)] does not make a directory read-only on Windows. Instead, it sets the DOS readonly attribute that prevents the directory from being deleted.

This method should be investigated to see if the following are feasible:

1. Have these methods return false for directories (meaning they cannot make the directory readonly)

2. Have the method insert a deny entry at the top of the DACL to deny write access.

Comments
EVALUATION The simplest solution is for setReadOnly to return false when the file is a directory.
26-09-2010