<div dir="ltr">Hi,<br><div><br></div><div><b>Observation:</b></div><div><br></div><div>On Unix and Windows respectively, the following code runs fine:</div><div><br></div><div>Unix:</div><div><font face="monospace">jshell> new URL("file://localhost/etc/hosts").openStream();<br>$8 ==> java.io.BufferedInputStream@59f95c5d</font></div><div><br></div><div>Windows:</div><div><font face="monospace">jshell> new java.net.URL("file://localhost/C:/Windows/System32/drivers/etc/hosts").openStream()<br>$13 ==> java.io.BufferedInputStream@33e5ccce</font></div><div><br></div><div>However, when we add a query parameter to the URL, the picture changes:</div><div><br></div><div>Unix:</div><div><font face="monospace">jshell> new URL("file://localhost/etc/hosts?name=value").openStream();<br>$9 ==> java.io.BufferedInputStream@4aa8f0b4</font></div><div><br></div><div>Windows:</div><div><font face="monospace">jshell> new java.net.URL("file://localhost/C:/Windows/System32/drivers/etc/hosts?name=value").openStream()<br>|  Exception java.io.FileNotFoundException: C:\Windows\System32\drivers\etc\hosts?name=value (The filename, directory name, or volume label syntax is incorrect)<br>|        at FileInputStream.open0 (Native Method)<br>|        at FileInputStream.open (FileInputStream.java:185)<br>|        at FileInputStream.<init> (FileInputStream.java:139)<br>|        at FileInputStream.<init> (FileInputStream.java:109)<br>|        at FileURLConnection.connect (FileURLConnection.java:83)<br>|        at FileURLConnection.getInputStream (FileURLConnection.java:185)<br>|        at URL.openStream (URL.java:1260)<br>|        at (#14:1)</font></div><div><br></div><div><br></div><div><b>Analysis:</b></div><div><br></div><div>Looking at the Windows implementation of sun.net.protocol.www.file.Handler, it indeed uses URL::getFile when constructing the file path, while the unix implementation uses URL::getPath.</div><div><br></div><div>Unlike the generic URI syntax described in RFC 3986, the file URI RFC 8082 does not include a query component in its syntax description.</div><div><br></div><div>This leaves the implementor the choice of ignoring query components (like we do for Unix) or rejecting the URL (which we effectively, while not explicitly, do for Windows).</div><div><br></div><div><b>Action:</b></div><div><br></div><div>I think it would make sense to align our implementations here. If we choose to do so, I think it would make most sense to adjust the Windows implementation to also ignore the query component by using URL::getPath instead of URL::getFile, like we currently do for Unix.</div><div><br></div><div>Thoughts?</div><div><br></div><div>Eirik. </div><div>  </div></div>