RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v15]

Alexey Ivanov aivanov at openjdk.org
Tue Aug 9 19:35:59 UTC 2022


On Tue, 9 Aug 2022 13:32:09 GMT, Abhishek Kumar <duke at openjdk.org> wrote:

>> JFileChooser - empty file size issue fixed. 
>> For empty file, now the size 0 KB.
>> Manual Test Case "FileSizeCheck.java" created.
>
> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   suggested review comments updated

src/java.desktop/share/classes/sun/swing/FilePane.java line 1202:

> 1200:                         updateMessageFormatPattern(kiloByteString,0);
> 1201:                     } else {
> 1202:                         updateMessageFormatPattern(kiloByteString,1);

There should a space after comma.

src/java.desktop/share/classes/sun/swing/FilePane.java line 1256:

> 1254:             mf.setFormat(0, nf);
> 1255:         }
> 1256:         private double formatToDoubleValue(long len) {

Should be static.

Please add a blank line between the methods.

test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 66:

> 64:         fc = new JFileChooser();
> 65:         Path dir = Paths.get(System.getProperty("test.src"));
> 66:         String [] tempFilesName = {"1-Empty-File", "2-File-2047-Byte", "3-File-2.5-KB", "4-File-999-KB", "5-File-1000-KB", "6-File-2.8-MB"};

Please break the long line. It's a common practice to code into 80 columns, or 100 at maximum. This line has 140 columns.

test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 67:

> 65:         Path dir = Paths.get(System.getProperty("test.src"));
> 66:         String [] tempFilesName = {"1-Empty-File", "2-File-2047-Byte", "3-File-2.5-KB", "4-File-999-KB", "5-File-1000-KB", "6-File-2.8-MB"};
> 67:         int [] tempFilesSize = {0, 2047, 2500, 999000, 1000000, 2800000};

Hint: You can use `_` as a group separator in numeric literals: 1_000_000 is more readable.

test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 93:

> 91: 
> 92:     public static void main(String args[]) throws InterruptedException, InvocationTargetException {
> 93:         passFailJFrame = new PassFailJFrame("JFileChooser Test Instructions" , INSTRUCTIONS, 5, 19, 35);

This line should also be wrapped; wrapping after the first parameter looked better.

(There should be no space before the comma in the argument list.)

test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 99:

> 97:                     test();
> 98:                 }
> 99:             });

I suggest using method reference:

Suggestion:

            SwingUtilities.invokeAndWait(FileSizeCheck::test);

-------------

PR: https://git.openjdk.org/jdk/pull/9327



More information about the client-libs-dev mailing list