toRealPath throws InternalError: Should not get here on Windows (paths with junctions)

Dawid Weiss dawid.weiss at
Tue Mar 15 11:19:54 UTC 2016

I couldn't find an appropriate bug in bugzilla, but this fails
reliably for me with Java 8 and 9 on Windows 10, 64-bit:

mkdir foo
mklink /J bar foo
cd bar
java -cp Test .

where is as simple as:

import java.nio.file.*;

public class Test {
  public static void main(String[] args) throws Exception {
    System.out.println("p.toRealPath(): " + Paths.get(args[0]).toRealPath());

The thrown error shows:

Exception in thread "main" java.lang.InternalError: Should not get here
        at sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native
        at sun.nio.fs.WindowsLinkSupport.getFinalPath(Unknown Source)
        at sun.nio.fs.WindowsLinkSupport.getRealPath(Unknown Source)
        at sun.nio.fs.WindowsPath.toRealPath(Unknown Source)
        at sun.nio.fs.WindowsPath.toRealPath(Unknown Source)

Is this just me? :)


More information about the core-libs-dev mailing list