JDK-4858457 : File.getCanonicalPath() throws IOException when invoked with "nul" (win)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2003-05-05
  • Updated: 2013-08-30
  • Resolved: 2013-08-15
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.
8 b105Fixed
Related Reports
Relates :  
Relates :  
Relates :  
###@###.### 2003-05-05

J2SE Version (please include all output from java -version flag):

J:\borsotti\jtest>java -version
  java version "1.4.1_01"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
  Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


  java version "1.4.2-rc"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b20)
  Java HotSpot(TM) Client VM (build 1.4.2-rc-b20, mixed mode)

Does this problem occur on J2SE 1.3, 1.4 or 1.4.1?  Yes / No (pick one)
 Yes on 1.4.1
 No  pm 1.4 and 1.3.1

Operating System Configuration Information (be specific):
 NT service pack 5 

Hardware Configuration Information (be specific):
 Compaq DeskPro

Bug Description:
  java.io.IOException exception throws on getCanonicalPath method when
  a file "nul" is created on Window system.

Steps to Reproduce (be specific):

 - Compile and run it.
 - A File for "nul" is created (i.e. for the name that is used
   in Windows to denote the null device).
 - A writer is created, successfully.
 - The getCanonicalPath() methid is invoked, which throws an exception:

  >java Fnull
Exception in thread "main" java.io.IOException: No such file or
        at java.io.WinNTFileSystem.canonicalize(Native Method)
        at java.io.File.getCanonicalPath(File.java:513)
        at Fnull.main(Fnull.java:6)

  This should not occur because a file on which a Writer can be
  successfully created should also have a canonical name.

Test program (Fnull.java):
  import java.io.*;
  public class Fnull {
      public static void main(String[] args) throws IOException {
        File f = new File("nul");
        FileWriter out = new FileWriter(f);
        String s = f.getCanonicalPath();

The file named "nul" is actually not created because it is a reserved name in windows.

EVALUATION wfullpath will return this syntax for all windows devices. This is a valid UNC path. Probably the best thing to do is modify wdots to allow this syntax. We need to verify that we do not introduce a regression of 4514340.

EVALUATION wfullpath returns "\\.\nul" for files like this, which is disallowed by the wdots check which was added in the fix for 4514340. This will not be fixed in Mantis. ###@###.### 2003-05-05