<div dir="ltr"><div><br></div><div>Consider the following scenario where a valid Java source file is compiled in a directory containing a sibling file with a colon in its file name:<br><br><font face="monospace">Z:\>dir /B<br>file:txt<br>HelloWorld.java</font><br><br>Compilation fails as follows:</div><div><br><font face="monospace">Z:\>javac HelloWorld.java<br>HelloWorld.java:1: error: cannot access unnamed package<br>public class HelloWorld {<br>^<br>  error accessing directory Z:\invalid-pathjava.nio.file.InvalidPathException: Illegal char <:> at index 4: file:txt<br>1 error<br>printing javac parameters to: Z:\invalid-path\javac.20240821_151610.args</font><br></div><div><br></div><div>The "error accessing directory" message seems to have been introduced in JDK-8177332.</div><div><br></div><div>The root exception seems to be thrown in WindowsPathParser.normalize.</div><div><br></div><div>Questions:</div><div><br></div><div>o Is this kind of failure expected according to the JLS and/or common sense?</div><div>o If yes, would it be worthwhile to improve the error reporting?  "Cannot access unnamed package" is not super helpful, "error accessing directory" is also somewhat vague.</div><div>o At the very least, should we add a space in the IOException message thrown by DirectoryContainer.list, to separate the file path from the InvalidPathException toString?</div><div><br></div><div>Cheers,</div><div>Eirik. </div></div>