JDK-6722636 : File.renameTo() fail conditions are non-clear
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-07-04
  • Updated: 2011-03-17
  • Resolved: 2008-07-07
Related Reports
Duplicate :  
Description
The problem is in the following phrase:
-----------------------------------
     Whether or not this method can move a file from one filesystem to another is platform-dependent. The return value should always be checked to make sure that the rename operation was successful.
------------------------------------

It seems that accordingly with such specification attempt to move file from one filesystem to another is single legal reason to avoid renaming.

However there are at least following reasons for renaming to fail:

* native platform does not support some kinds of renaming (for example, renaming directories in the BREW platform)
* source File instance represents abstract pathname for which there is no existing file 
* there are no write permissions (in the filesystem meaning) for directory containing either source or destination File instance (or for source/destination files)
* destination File instance repesents abstract pathname for which file can't be created
due to the filesystem restrictions
* destination File instance repesents abstract pathname assuming creation of the several intermediate subdirectories

I think more general wording should be provided about possible fail of renaming.

Comments
EVALUATION Wording for renameTo() had been udpated in 1.5 to clarify that indeed the renameto operation is inherently system-dependent, for various reasons. The submitter obviously cited the 1.4 version of the API spec.
07-07-2008