Given this directory content
10/01/2025 05:57 PM <DIR> dir
10/01/2025 05:58 PM <SYMLINKD> dirlink [dir]
10/01/2025 05:58 PM <JUNCTION> junction [C:\Users\bpb\dev\bugs\dir]
10/01/2025 05:58 PM <SYMLINK> symlink [dir]
we get the following results
jshell> Path.of("dir").toRealPath()
$7 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("dirlink").toRealPath()
$8 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("junction").toRealPath()
$9 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("symlink").toRealPath()
| Exception java.nio.file.AccessDeniedException: symlink
| at WindowsException.translateToIOException (WindowsException.java:89)
| at WindowsException.rethrowAsIOException (WindowsException.java:103)
| at WindowsException.rethrowAsIOException (WindowsException.java:108)
| at WindowsLinkSupport.getFinalPath (WindowsLinkSupport.java:102)
| at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:263)
| at WindowsPath.toRealPath (WindowsPath.java:907)
| at WindowsPath.toRealPath (WindowsPath.java:42)
| at (#10:1)
9:55
jshell> Path.of("symlink", "subdir").toRealPath()
$11 ==> C:\Users\bpb\dev\bugs\dir\subdir
where "subdir" is a dub-directory of "dir".
10/01/2025 05:57 PM <DIR> dir
10/01/2025 05:58 PM <SYMLINKD> dirlink [dir]
10/01/2025 05:58 PM <JUNCTION> junction [C:\Users\bpb\dev\bugs\dir]
10/01/2025 05:58 PM <SYMLINK> symlink [dir]
we get the following results
jshell> Path.of("dir").toRealPath()
$7 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("dirlink").toRealPath()
$8 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("junction").toRealPath()
$9 ==> C:\Users\bpb\dev\bugs\dir
jshell> Path.of("symlink").toRealPath()
| Exception java.nio.file.AccessDeniedException: symlink
| at WindowsException.translateToIOException (WindowsException.java:89)
| at WindowsException.rethrowAsIOException (WindowsException.java:103)
| at WindowsException.rethrowAsIOException (WindowsException.java:108)
| at WindowsLinkSupport.getFinalPath (WindowsLinkSupport.java:102)
| at WindowsLinkSupport.getRealPath (WindowsLinkSupport.java:263)
| at WindowsPath.toRealPath (WindowsPath.java:907)
| at WindowsPath.toRealPath (WindowsPath.java:42)
| at (#10:1)
9:55
jshell> Path.of("symlink", "subdir").toRealPath()
$11 ==> C:\Users\bpb\dev\bugs\dir\subdir
where "subdir" is a dub-directory of "dir".
- relates to
-
JDK-8369059 File.getCanonicalPath does not resolve terminal symbolic link (win)
-
- Closed
-