<Swing Dev> [11][JDK-8196673] JFileChooser throws InvalidPathException when changing to directory with added space

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Feb 16 19:26:59 UTC 2018


On 02/16/2018 10:31 AM, Krishna Addepalli wrote:

> “It looks really odd that Java may create a directory but may not 
> change to it. It also introduces compatibility problems with files 
> created on other platforms, downloads, unpacked archives, etc. “
>
> Semyon, could you clarify this. I mean, how can Java create a 
> directory ending with space, when Windows does not allow it. As 
> mentioned in the bug JDK-6578565, Win32 API CreateDirectoryW silently 
> trims the trailing white spaces from a directory name, whereas the 
> alternative API SHCreateDirectoryEXW produces an error if the path is 
> illegal.
>
Sure. You can use special path syntax that prefixed with \\?\

--Semyon
>
> Thanks,
>
> Krishna
>
> *From:*Semyon Sadetsky
> *Sent:* Friday, February 16, 2018 11:10 PM
> *To:* Phil Race <philip.race at oracle.com>; Krishna Addepalli 
> <krishna.addepalli at oracle.com>; swing-dev at openjdk.java.net
> *Subject:* Re: <Swing Dev> [11][JDK-8196673] JFileChooser throws 
> InvalidPathException when changing to directory with added space
>
> I take a look at the 6578565. They said that windows specifies this in 
> https://msdn.microsoft.com/en-US/library/aa365247.aspx. And this doc says:
>
> "Do not end a file or directory name with a space or a period. 
> Although the underlying file system may support such names, the 
> Windows shell and user interface does not. However, it is acceptable 
> to specify a period as the first character of a name. For example, 
> ".temp"."
>
> That means that only Windows shell doesn't support it. This may be not 
> enough a justification since NIO works in headless mode as well. It is 
> the client-libs that should take care about following the shell specs 
> not core-libs. NIO should support spaces if underling OS supports it.
>
> It looks really odd that Java may create a directory but may not 
> change to it. It also introduces compatibility problems with files 
> created on other platforms, downloads, unpacked archives, etc.
>
> --Semyon
>
> Do not end a file or directory name
>
>     Krishna Addepalli <krishna.addepalli at oracle.com>
>     <mailto:krishna.addepalli at oracle.com>
>
> with a space or a period. Although the underlying file system may 
> support such names, the Windows shell and user interface does not. 
> However, it is acceptable to specify a period as the first character 
> of a name. For example, ".temp".
>
> On 02/16/2018 09:08 AM, Phil Race wrote:
>
>     Right, what I said was that perhaps nio is behaving as specified
>     in this case.
>     If a standalone nio program can be written that shows nio
>     contravening its spec.
>     then a bug should be raised against nio. I did not verify what the
>     case is there ..
>     I just suggested that should be investigated.
>
>     Vagueness that it is an nio problem without pointing to why just
>     makes me
>     have to investigate it myself to see why .. I'd prefer that the
>     bug owner do that :-)
>
>     But otherwise (no nio bug)  we'll have to deal with what nio
>     specifies.
>     If we can fix it locally *and* file a bug against nio then that is
>     also an issue.
>     Also nio may take a while to get to it ..
>
>     -phil
>
>     On 02/16/2018 08:56 AM, Krishna Addepalli wrote:
>
>         Hi Semyon,
>
>         I had a discussion with Sergey,Phil regarding this. While
>         there was a similar bug filed against Core-libs
>         (https://bugs.openjdk.java.net/browse/JDK-6578565) , it was
>         closed out as not an issue.
>
>         I have checked it on Java8, and it behaves correctly on
>         Windows – it trims the paths and then creates/selects the folder.
>
>         From Java9 onwards, the InvalidPathException is thrown, since
>         ShellFolder.java file uses nio to get the path, and the nio
>         throws the exception as reported in the bug.
>
>         Phil suggested that, we should fix the bug at our level if we
>         can, since nio may not consider this to be a problem at their
>         level.
>
>         Hence this suggested fix.
>
>         Thanks,
>
>         Krishna
>
>         *From:*Semyon Sadetsky
>         *Sent:* Friday, February 16, 2018 10:04 PM
>         *To:* Krishna Addepalli <krishna.addepalli at oracle.com>
>         <mailto:krishna.addepalli at oracle.com>;
>         swing-dev at openjdk.java.net <mailto:swing-dev at openjdk.java.net>
>         *Subject:* Re: <Swing Dev> [11][JDK-8196673] JFileChooser
>         throws InvalidPathException when changing to directory with
>         added space
>
>         According to Pardeep Sharma comment the bug is reproducible
>         since 6u45. Do you confirm this or it is a regression
>         introduced in 9?
>
>         From the stack trace it doesn't look as a client-libs issue
>         but a NIO issue.
>
>         --Semyon
>
>         On 02/16/2018 04:40 AM, Krishna Addepalli wrote:
>
>             Hi Sergey, Phil
>
>             Please review a fix for JDK-8196673:
>             https://bugs.openjdk.java.net/browse/JDK-8196673
>
>             Webrev:
>             http://cr.openjdk.java.net/~kaddepalli/8196673/webrev00
>             <http://cr.openjdk.java.net/%7Ekaddepalli/8196673/webrev00>
>
>             The problem is in Java9 and later, when a directory path
>             that contains leading/trailing space is provided, it
>             throws an InvalidPathException. As per Phil’s
>             recommendation, I have added a simple fix, which will trim
>             the path for Windows, whereas for other platforms, it
>             keeps it as it is.
>
>             Thanks,
>
>             Krishna
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20180216/0dadfdee/attachment.html>


More information about the swing-dev mailing list