JDK-8221824 : Build failure with MSVS 2013 after JDK-8218418
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2019-04-02
  • Updated: 2019-06-27
  • Resolved: 2019-04-02
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.
JDK 13
13 b15Fixed
Related Reports
Relates :  
Relates :  
Description
c:/cygwin64/home/windows/worker/jdkX-windows/build/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c(1069) : error C2065: 'SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE' : undeclared identifier
make[3]: *** [Lib-java.base.gmk:72: /cygdrive/c/cygwin64/home/windows/worker/jdkX-windows/build/build/windows-x86_64-server-fastdebug/support/native/java.base/libnio/WindowsNativeDispatcher.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [make/Main.gmk:215: java.base-libs] Error 2

I think we need to check that identifier is available.
Comments
This fix is definitely incorrect. For example, for a JDK built on Windows 7 with the VS 2017 toolchain, the exception message for attempted unprivileged creation of a symbolic link changes from Exception in thread "main" java.nio.file.FileSystemException: link: A required privilege is not held by the client. before the change to Exception in thread "main" java.nio.file.FileSystemException: link: The parameter is incorrect. after the change as SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is defined in the SDK but not in the Windows 7 runtime environment. Therefore when it gets ORed into the flags it causes a different exception to be thrown by CreateSymbolicLinkW.
05-04-2019

Yeah, well, it is old. I don't think this is a reason enough to break it with simple stuff like this. This suffices to pass the build: diff -r 35794e8db61b src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c --- a/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Tue Apr 02 10:04:35 2019 +0200 +++ b/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c Tue Apr 02 12:26:27 2019 +0200 @@ -1066,6 +1066,9 @@ // Allow creation of symbolic links when the process is not elevated. // Developer Mode must be enabled for this option to function, otherwise - // it will be ignored. - DWORD dwFlags = (DWORD)flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + // it will be ignored. Check that symbol is available in current build SDK. + DWORD dwFlags = (DWORD)flags; +#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE + dwFlags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; +#endif // On Windows 64-bit this appears to succeed even when there are
02-04-2019

Microsoft Visual Studio 2013 seems quite old, I wonder if it builds on the 2015 release. Oracle builds currently use Microsoft Visual Studio 2017 (since JDK-8219988).
02-04-2019

* Toolchain: microsoft (Microsoft Visual Studio 2013) * C Compiler: Version 18.00.31101 (at /cygdrive/c/progra~2/micros~1.0/vc/bin/x86_am~1/cl) * C++ Compiler: Version 18.00.31101 (at /cygdrive/c/progra~2/micros~1.0/vc/bin/x86_am~1/cl)
02-04-2019

Which SDK and Microsoft Visual Studio are you using?
02-04-2019

Whether SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is supported or not depends on the version of Windows at run-time, not the SDK/toolchain. So I think the patch for this will be to define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE if is not set. That said, I think JDK-8218418 needs to be re-examined anyway to make sure that SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is silently ignored on older versions of Windows.
02-04-2019