-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.4.2_06
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In JDK 1.4.2_06, it is no longer possible to use FileSystemView.getSystemDisplayName() on Windows for a removable drive when there is no media present in the drive. This worked as recently as JDK 1.4.2_05. FileSystemView.getSystemIcon() fails as well.
The crux of the problem seems to be that File.getCanonicalPath() fails on a removable drive root when there is no media. FileSystemView.getSystemDisplayName() now relies on File.getCanonicalPath(), where previously it did not. File.getCanonicalPath() should never fail on any drive root path, for any reason, since the canonical path is always the root path itself.
The problem is not reproducible with J2SE 5.0.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached program on a Windows system using both JDK 1.4.2_05 and JDK 1.4.2_06 and compare the results.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This is the output on my machine when run under JDK 1.4.2_05:
java runtime = 1.4.2_04-b05
root: A:display name = 3½ Floppy (A:)
root: C:display name = System Volume (C:)
root: D:display name = Data Volume (D:)
root: E:display name = ADE Volume (E:)
root: F:display name = CD Drive (F:)
ACTUAL -
This is the output on my machine under JDK 1.4.2_06:
java runtime = 1.4.2_06-b03
root: A:FileSystemView.getShellFolder: f=A:java.io.FileNotFoundException: File A:\ not found
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:48)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:36)
at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:236)
at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.
java:486)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
Exception getting display name
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
root: C:display name = System Volume (C:)
root: D:display name = Data Volume (D:)
root: E:display name = ADE Volume (E:)
root: F:FileSystemView.getShellFolder: f=F:java.io.FileNotFoundException: File F:\ not found
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:48)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:36)
at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:236)
at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.
java:486)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
Exception getting display name
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
[E:\ade\jeras_jdev\jdev\src]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.io.IOException;
import javax.swing.filechooser.FileSystemView;
public class SystemDisplayNameTest
{
public static void main(String[] args)
{
System.out.println("java runtime = " + System.getProperty("java.runtime.version"));
System.out.println();
final FileSystemView fsv = FileSystemView.getFileSystemView();
final File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++)
{
final File root = fsv.createFileObject(roots[i].getPath());
System.out.println("root: " + root);
try
{
System.out.println("display name = " + fsv.getSystemDisplayName(root));
}
catch (Exception ex)
{
System.err.println("Exception getting display name");
ex.printStackTrace();
}
System.out.println();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None. One must avoid calling FileSystem.getSystemDisplayName() on a removable drive root, for example by using FileSystemView.isFloppyDrive() and/or File.exists().
###@###.### 2004-11-08 19:41:03 GMT
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In JDK 1.4.2_06, it is no longer possible to use FileSystemView.getSystemDisplayName() on Windows for a removable drive when there is no media present in the drive. This worked as recently as JDK 1.4.2_05. FileSystemView.getSystemIcon() fails as well.
The crux of the problem seems to be that File.getCanonicalPath() fails on a removable drive root when there is no media. FileSystemView.getSystemDisplayName() now relies on File.getCanonicalPath(), where previously it did not. File.getCanonicalPath() should never fail on any drive root path, for any reason, since the canonical path is always the root path itself.
The problem is not reproducible with J2SE 5.0.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached program on a Windows system using both JDK 1.4.2_05 and JDK 1.4.2_06 and compare the results.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This is the output on my machine when run under JDK 1.4.2_05:
java runtime = 1.4.2_04-b05
root: A:display name = 3½ Floppy (A:)
root: C:display name = System Volume (C:)
root: D:display name = Data Volume (D:)
root: E:display name = ADE Volume (E:)
root: F:display name = CD Drive (F:)
ACTUAL -
This is the output on my machine under JDK 1.4.2_06:
java runtime = 1.4.2_06-b03
root: A:FileSystemView.getShellFolder: f=A:java.io.FileNotFoundException: File A:\ not found
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:48)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:36)
at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:236)
at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.
java:486)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
Exception getting display name
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
root: C:display name = System Volume (C:)
root: D:display name = Data Volume (D:)
root: E:display name = ADE Volume (E:)
root: F:FileSystemView.getShellFolder: f=F:java.io.FileNotFoundException: File F:\ not found
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:48)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Win32ShellFo
lderManager2.java:36)
at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:236)
at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.
java:486)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
Exception getting display name
java.lang.NullPointerException
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:144)
at SystemDisplayNameTest.main(SystemDisplayNameTest.java:20)
[E:\ade\jeras_jdev\jdev\src]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.io.IOException;
import javax.swing.filechooser.FileSystemView;
public class SystemDisplayNameTest
{
public static void main(String[] args)
{
System.out.println("java runtime = " + System.getProperty("java.runtime.version"));
System.out.println();
final FileSystemView fsv = FileSystemView.getFileSystemView();
final File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++)
{
final File root = fsv.createFileObject(roots[i].getPath());
System.out.println("root: " + root);
try
{
System.out.println("display name = " + fsv.getSystemDisplayName(root));
}
catch (Exception ex)
{
System.err.println("Exception getting display name");
ex.printStackTrace();
}
System.out.println();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None. One must avoid calling FileSystem.getSystemDisplayName() on a removable drive root, for example by using FileSystemView.isFloppyDrive() and/or File.exists().
###@###.### 2004-11-08 19:41:03 GMT
- relates to
-
JDK-4089199 File creation on removable drives without a disk brings up a dialog (win)
- Resolved
-
JDK-4869950 NPE if JFileChooser.setCurrentDirectory() called twice with non-canonical file
- Closed