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

Abhishek Kumar duke at openjdk.org
Wed Aug 24 16:45:38 UTC 2022


On Mon, 22 Aug 2022 15:40:33 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Updated as per review comment
>
> src/java.desktop/share/classes/sun/swing/FilePane.java line 1187:
> 
>> 1185:             // TODO: it's rather a temporary trick, to be revised
>> 1186:             String text;
>> 1187:             Object[] objs = new Object[1];
> 
> I suggest moving this declaration into the following block:
> 
> 
>             } else if (value instanceof Long len) {
>                 Object[] objs = new Object[1];
> 
>                 if (listViewWindowsStyle) {
> 
> 
> This will reduce the visibility of the variable to the block where it's used.
> 
> Giving it a descriptive name would also be better. Is `fileSize` good enough? `displayedFileSize`?

Implemented the suggested changes. Replaced the variable name "objs" with "displayedFileSize".

> test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 65:
> 
>> 63:         JFrame frame = new JFrame("JFileChooser File Size test");
>> 64:         JFileChooser fc = new JFileChooser();
>> 65:         Path dir = Paths.get(System.getProperty("test.src"));
> 
> When run with jtreg, it creates the files in the test source tree, which is probably not what we want. If the files aren't removed, they'll be left in the source tree and may prevent further updates to the source.
> 
> Should this always default to the current directory? When `jtreg` runs a test, the current directory is a `scratch` directory which is cleaned between the tests if the test passes, if the test fails, the contents is copied to the test log directory.

I have changed the directory from "test.src" to current directory as suggested.

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

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



More information about the client-libs-dev mailing list