JDK-4241259 : java.io.File.getParentFile() returns non directory
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-05-26
  • Updated: 2011-05-30
  • Resolved: 2011-05-30
Related Reports
Relates :  
Description

Name: dbT83986			Date: 05/25/99


Given a UNC path such as \\thor\apps\java
the sequence of parents returned is
\\thor\apps
\\thor
\
However, the last two in this sequence are not 
directories, which contradicts the documentation 
for this method. The ".." notation works to obtain
a parent directory, but does not work to change to a different share.
i.e.
 \\thor\apps\..\code is not a synonym for \\thor\code
Thus for UNC paths the 'prefix' should be \\machine\share and not just the \\ part. Of course it would be easier to change the documentation ...

I was attempting to create a portable method to determine the relative path between two absolute paths (if one exists), but the existing File
class does not provide sufficient information about the file system to make this possible.
(Review ID: 83441) 
======================================================================

Comments
EVALUATION It would be way too risky to change the behvaior of getParentFile now. In the new file system API, the getParent method does the right thing with UNCs. Furthermore, Path defines a relativize method that addresses what we believe was the original requirement here.
30-05-2011