On Thu, 7 Sep 2023 08:33:39 GMT, Alan Bateman <al...@openjdk.org> wrote:
> Would it be possible to summarise how this behaves when File just represents > a prefix? Baseline: jshell> File f = new File("\\\?\") f ==> \? jshell> f.getCanonicalPath() | Exception java.io.IOException: Bad pathname | at WinNTFileSystem.canonicalize0 (Native Method) | at WinNTFileSystem.canonicalize (WinNTFileSystem.java:463) | at File.getCanonicalPath (File.java:626) | at (#2:1) jshell> f = new File("\\\?\\UNC\") f ==> \?\UNC jshell> f.getCanonicalPath() | Exception java.io.IOException: Bad pathname | at WinNTFileSystem.canonicalize0 (Native Method) | at WinNTFileSystem.canonicalize (WinNTFileSystem.java:463) | at File.getCanonicalPath (File.java:626) | at (#4:1) Proposed patch: jshell> File f = new File("\\\?\") f ==> \? jshell> f.getCanonicalPath() | Exception java.io.IOException: Bad pathname | at WinNTFileSystem.canonicalize0 (Native Method) | at WinNTFileSystem.canonicalize (WinNTFileSystem.java:472) | at File.getCanonicalPath (File.java:626) | at (#2:1) jshell> f = new File("\\\?\\UNC\") f ==> \?\UNC jshell> f.getCanonicalPath() $4 ==> "C:\\Users\\bpb\\dev\\jdk\\jdk\\UNC" Presumably the constructor removes the trailing `\`, hence I suppose the special case of `\?\UNC` should be checked in the code right after the proposed change. ------------- PR Comment: https://git.openjdk.org/jdk/pull/15603#issuecomment-1710409880