toRealPath throws InternalError: Should not get here on Windows (paths with junctions)
Dawid Weiss
dawid.weiss at gmail.com
Tue Mar 15 12:01:00 UTC 2016
I filed an issue (Review ID: JI-9032181). In any case, I checked with
Java 7, 8 and the ea:
Java(TM) SE Runtime Environment (build
9-ea+109-2016-03-09-181019.javare.4620.nc)
The issue only affects Windows 10 (tested on 64-bit only), Windows 7
behaves fine. The following sequence is enough to get the stack trace:
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());
}
}
and the stack trace:
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)
Dawid
On Tue, Mar 15, 2016 at 12:28 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 15/03/2016 11:19, Dawid Weiss wrote:
>>
>> 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 Test.java is as simple as:
>>
>> import java.io.*;
>> 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
>> Method)
>
> There are a number of win32 functions that this code uses GetProcAddress to
> get their address in kernel32. This dates back to when we had to support
> Windows XP. This should be cleaned up now. Doesn't explain why you are
> seeing though, can you submit a bug?
>
> -Alan
More information about the core-libs-dev
mailing list