-
Bug
-
Resolution: Fixed
-
P3
-
8, 11, 17, 18, 19
-
b20
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
"Previously worked in the Release": Never worked?
* Linux: bug
* Windows: OK?
* Probably any Java version
A DESCRIPTION OF THE PROBLEM :
An empty (0 bytes) file is displayed as 1 KB in the "Details" view.
File choosers in other UI toolkits (Qt, GTK, native win32) display the size
correctly as "0 B" or "0 bytes".
There is a suspicious line in src/java.desktop/share/classes/sun/swing/FilePane.java:
MessageFormat.format(kiloByteString, (len == 0L) ? 1L : len);
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
0. Screenshot: https://i.imgur.com/1LguaBq.png
1. Run the attached test on *Linux*
2. Click the "Details" button in right-top corner
3. Size of the "TEST-EMPTY-FILE.txt" is displayed as "1 KB" instead of "0 KB"
(other sizes are displayed correctly - probably)
Note that Metal Look And Feel on *MS Windows* displays "0 bytes",
because it uses ShellFolder to set column values.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
public class Test {
public static void main(String[] args) throws IOException {
Path currentDir = Path.of(System.getProperty("user.dir"));
// create empty file
Path emptyFile = currentDir.resolve("TEST-EMPTY-FILE.txt");
if (!Files.exists(emptyFile)) {
System.out.println("Creating " + emptyFile);
Files.createFile(emptyFile);
}
// show file chooser
SwingUtilities.invokeLater(() -> {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(currentDir.toFile());
fc.showOpenDialog(null);
});
}
}
---------- END SOURCE ----------
FREQUENCY : always
"Previously worked in the Release": Never worked?
* Linux: bug
* Windows: OK?
* Probably any Java version
A DESCRIPTION OF THE PROBLEM :
An empty (0 bytes) file is displayed as 1 KB in the "Details" view.
File choosers in other UI toolkits (Qt, GTK, native win32) display the size
correctly as "0 B" or "0 bytes".
There is a suspicious line in src/java.desktop/share/classes/sun/swing/FilePane.java:
MessageFormat.format(kiloByteString, (len == 0L) ? 1L : len);
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
0. Screenshot: https://i.imgur.com/1LguaBq.png
1. Run the attached test on *Linux*
2. Click the "Details" button in right-top corner
3. Size of the "TEST-EMPTY-FILE.txt" is displayed as "1 KB" instead of "0 KB"
(other sizes are displayed correctly - probably)
Note that Metal Look And Feel on *MS Windows* displays "0 bytes",
because it uses ShellFolder to set column values.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
public class Test {
public static void main(String[] args) throws IOException {
Path currentDir = Path.of(System.getProperty("user.dir"));
// create empty file
Path emptyFile = currentDir.resolve("TEST-EMPTY-FILE.txt");
if (!Files.exists(emptyFile)) {
System.out.println("Creating " + emptyFile);
Files.createFile(emptyFile);
}
// show file chooser
SwingUtilities.invokeLater(() -> {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(currentDir.toFile());
fc.showOpenDialog(null);
});
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8295738 Automate javax/swing/JFileChooser/FileSizeCheck.java
-
- Resolved
-