<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Times New Roman \,serif";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p>“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. “<o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>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.<o:p></o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span style='color:#1F497D'><o:p> </o:p></span></a></p><p class=MsoNormal><span style='mso-bookmark:_MailEndCompose'><span style='color:#1F497D'>Thanks,<o:p></o:p></span></span></p><p class=MsoNormal><span style='mso-bookmark:_MailEndCompose'><span style='color:#1F497D'>Krishna<o:p></o:p></span></span></p><span style='mso-bookmark:_MailEndCompose'></span><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='color:windowtext'>From:</span></b><span style='color:windowtext'> Semyon Sadetsky <br><b>Sent:</b> Friday, February 16, 2018 11:10 PM<br><b>To:</b> Phil Race <philip.race@oracle.com>; Krishna Addepalli <krishna.addepalli@oracle.com>; swing-dev@openjdk.java.net<br><b>Subject:</b> Re: <Swing Dev> [11][JDK-8196673] JFileChooser throws InvalidPathException when changing to directory with added space<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p>I take a look at the 6578565. They said that windows specifies this in <a href="https://msdn.microsoft.com/en-US/library/aa365247.aspx">https://msdn.microsoft.com/en-US/library/aa365247.aspx</a>. And this doc says:<span style='font-size:12.0pt'><o:p></o:p></span></p><p>"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"."<o:p></o:p></p><p>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.<o:p></o:p></p><p>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. <o:p></o:p></p><p>--Semyon<o:p></o:p></p><p>Do not end a file or directory name <o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Krishna Addepalli <a href="mailto:krishna.addepalli@oracle.com"><krishna.addepalli@oracle.com></a><o:p></o:p></p></blockquote><p class=MsoNormal>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".<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On 02/16/2018 09:08 AM, Phil Race wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal style='margin-bottom:12.0pt'>Right, what I said was that perhaps nio is behaving as specified in this case.<br>If a standalone nio program can be written that shows nio contravening its spec.<br>then a bug should be raised against nio. I did not verify what the case is there ..<br>I just suggested that should be investigated.<br><br>Vagueness that it is an nio problem without pointing to why just makes me<br>have to investigate it myself to see why .. I'd prefer that the bug owner do that :-)<br><br>But otherwise (no nio bug)  we'll have to deal with what nio specifies.<br>If we can fix it locally *and* file a bug against nio then that is also an issue.<br>Also nio may take a while to get to it ..<br><br>-phil<o:p></o:p></p><div><p class=MsoNormal>On 02/16/2018 08:56 AM, Krishna Addepalli wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='color:#1F497D'>Hi Semyon, </span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>I had a discussion with Sergey,Phil regarding this. While there was a similar bug filed against Core-libs (<a href="https://bugs.openjdk.java.net/browse/JDK-6578565">https://bugs.openjdk.java.net/browse/JDK-6578565</a>) , it was closed out as not an issue.</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>I have checked it on Java8, and it behaves correctly on Windows – it trims the paths and then creates/selects the folder. </span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>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.</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>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.</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Hence this suggested fix.</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Thanks,</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>Krishna</span><o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'> </span><o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='color:windowtext'>From:</span></b><span style='color:windowtext'> Semyon Sadetsky <br><b>Sent:</b> Friday, February 16, 2018 10:04 PM<br><b>To:</b> Krishna Addepalli <a href="mailto:krishna.addepalli@oracle.com"><krishna.addepalli@oracle.com></a>; <a href="mailto:swing-dev@openjdk.java.net">swing-dev@openjdk.java.net</a><br><b>Subject:</b> Re: <Swing Dev> [11][JDK-8196673] JFileChooser throws InvalidPathException when changing to directory with added space</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p>According to Pardeep Sharma comment the bug is reproducible since 6u45. Do you confirm this or it is a regression introduced in 9?<o:p></o:p></p><p>From the stack trace it doesn't look as a client-libs issue but a NIO issue.<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>--Semyon<o:p></o:p></p><div><p class=MsoNormal>On 02/16/2018 04:40 AM, Krishna Addepalli wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Hi Sergey, Phil<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Please review a fix for JDK-8196673: <a href="https://bugs.openjdk.java.net/browse/JDK-8196673">https://bugs.openjdk.java.net/browse/JDK-8196673</a><o:p></o:p></p><p class=MsoNormal>Webrev: <a href="http://cr.openjdk.java.net/%7Ekaddepalli/8196673/webrev00">http://cr.openjdk.java.net/~kaddepalli/8196673/webrev00</a><o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Krishna<o:p></o:p></p></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman ,serif",serif'> </span><o:p></o:p></p></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p></div></body></html>