JDK-8151915 : (fs) toRealPath on a path with a junction fails with an "java.lang.InternalError: Should not get here"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u74
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: windows_10
  • CPU: x86
  • Submitted: 2016-03-15
  • Updated: 2019-10-19
  • Resolved: 2019-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
Tested on Java 8, 9 (various versions) and recent EA:

Java(TM) SE Runtime Environment (build 9-ea+109-2016-03-09-181019.javare.4620.nc)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+109-2016-03-09-181019.javare.4620.nc, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Windows 10, 64-bit.

A DESCRIPTION OF THE PROBLEM :
Internal error on toRealPath when path contains a junction.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
mkdir foo
mklink /J bar foo
java -cp . Test bar

The Test.java code is:
import java.io.*;
import java.nio.file.*;

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


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should work.
ACTUAL -
Throws an exception:

Exception in thread "main" java.lang.InternalError: Should not get here
        at sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native Method)
        at sun.nio.fs.WindowsLinkSupport.getFinalPath(WindowsLinkSupport.java:77)
        at sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:242)
        at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:840)
        at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44)
        at Test.main(Test.java:10)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Trivial:

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

CUSTOMER SUBMITTED WORKAROUND :
None known.


Comments
Just to add some more info, should this ever be revived. A customer also saw this error: java.lang.InternalError: Should not get here at sun.nio.fs.WindowsNativeDispatcher.GetFinalPathNameByHandle(Native Method) at sun.nio.fs.WindowsLinkSupport.getFinalPath(WindowsLinkSupport.java:77) at sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:242) at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:836) at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44) This was on Windows 10, using Java 1.8.0_192 (64bit). He was trying to access a Microsoft OneDrive folder (i.e. C:\Users\USERNAME\OneDrive\Music).
19-10-2019

This problem has never been observed except in the instance described by the submitter. Furthermore the code in which it would occur were it reproducible was removed by the fix for JDK-8152043. Resolving as a non-issue.
21-08-2019

Update from filer: I did a bit more digging. I can reproduce this every time on my machine if: 1) I open cmd from total commander (64 bit or 32 bit, doesn't matter); 2) from that cmd run the simple example in Java that attempts to resolve real path; this ends in InternalError. On the other hand, if I run cmd from the start menu, everything works fine. total commander is clean (checked md5 to rule out viruses or whatever). I have no idea what this is -- I think the problem can be marked as "non-reproducible", maybe it's a glitch in my system somewhere. Sorry for the noise. Dawid
05-04-2016

Additional information from filer (Dawid Weiss) via email. This must be more complicated than I thought because the same code passes with flying colors on another (fairly fresh install) of Windows 10... I don't know what the difference is, to be honest (I have Windows 10 Pro N). I'll try to dig deeper, time permitting, but perhaps a comment on the eventual Jira issue would be sensible (can't do it myself, no Jira access).
15-03-2016