JDK-8046686 : (fs) Files.CreateSymbolicLink failed with InternalError "Should not get here" (win)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u5
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2014-06-12
  • Updated: 2019-08-21
  • 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 :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Client VM (build 25.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
java.lang.InternalError: Should not get here
	at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)
	at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink(Unknown Source)
	at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(Unknown Source)
	at java.nio.file.Files.createSymbolicLink(Unknown Source)
	at org.eclipse.jgit.util.FileUtil.createSymLink(FileUtil.java:96)
	at org.eclipse.jgit.util.FS_Win32_Java7.detectSymlinkSupport(FS_Win32_Java7.java:80)
	at org.eclipse.jgit.util.FS_Win32_Java7.supportsSymlinks(FS_Win32_Java7.java:71)
	at org.eclipse.egit.core.ContainerTreeIterator$ResourceEntry.<init>(ContainerTreeIterator.java:295)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample code on windows platform.

When I run it as Administrator - no problem.  When I run it as user in administrator group - it doesn����t work. 

I checked the setting in temporary folder  - my user has  FULL Access to targed directory. 

Other informations could be found in https://bugs.eclipse.org/bugs/show_bug.cgi?id=436137
 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Link created or some IOException about bad rights, or root cause of the problem.
ACTUAL -
Exception in thread "main" java.lang.InternalError: Should not get here
	at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.InternalError: Should not get here
	at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)
	at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink(Unknown Source)
	at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(Unknown Source)
	at java.nio.file.Files.createSymbolicLink(Unknown Source)
	at uu.os.samples.TestSimlink.createSymLink(TestSimlink.java:47)
	at uu.os.samples.TestSimlink.detectSymlinkSupport(TestSimlink.java:29)
	at uu.os.samples.TestSimlink.main(TestSimlink.java:19)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package uu.os.samples;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;

public class TestSimlink {
  
  static boolean supportSymlinks = false;

  public static void main(String[] args) {

    TestSimlink tsm = new TestSimlink();
    tsm.detectSymlinkSupport();
    System.out.println("Result: " + supportSymlinks);
  }

  private void detectSymlinkSupport() {
    File tempFile = null;
    try {
      tempFile = File.createTempFile("tempsymlinktarget2", ""); //$NON-NLS-1$ //$NON-NLS-2$
      File linkName = new File(tempFile.getParentFile(), "tempsymlink2"); //$NON-NLS-1$
      createSymLink(linkName, tempFile.getPath());
      supportSymlinks = Boolean.TRUE;
      linkName.delete();
    } catch (IOException e) {
      supportSymlinks = Boolean.FALSE;
    } finally { 
      if (tempFile != null)
        tempFile.delete();
    }
  }

  public static void createSymLink(File path, String target) throws IOException {
    Path nioPath = path.toPath();
    if (Files.exists(nioPath, LinkOption.NOFOLLOW_LINKS))
      Files.delete(nioPath);
    if (true)  
      target = target.replace('/', '\\');
    Path nioTarget = new File(target).toPath();
    Files.createSymbolicLink(nioPath, nioTarget);
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Run java as Administrator


Comments
There has been no sighting of this since it was reported five years ago and furthermore the code in question was removed by the fix for JDK-8152043. Resolving as a non-issue.
21-08-2019

I think we need to locate a system where this duplicates. We haven't had any other bug reports on this (to my knowledge).
09-12-2014

Indeed the native method CreateSymbolicLink0 has this block: if (CreateSymbolicLink_func == NULL) { JNU_ThrowInternalError(env, "Should not get here"); return; } where the internal error will be thrown if GetProcAddress() called from initIDs() cannot retrieve the address of CreateSymbolicLinkW(). Given that the Windows version is apparently Windows 7 Service Pack 1 (Version 6.1.7601), the symbol should in theory be able to be retrieved. Sounds like there must be some problem with the system for which this issue was reported. One question here though is whether the result of GetLastError() should be cached for later reference if the GetProcAddress() result is NULL.
09-12-2014

I checked two Windows 7 machines and the test fails as expected with "A required privilege is not held by the client". This is expected because non-privileged users on Windows are not allowed to created symbolic links.
16-06-2014

The "Should not reach here" means that it doesn't have the address of the win32 CreateSymbolicLinkW function. It needs more investigation to understand how this is possible.
12-06-2014