JDK-6916645 : FileObject.toUri produces unusable URI for UNC paths
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-01-13
  • Updated: 2014-02-04
Related Reports
Relates :  
Description
When an annotation processor is working with a file - say, a resource found in the source location - and calls FileObject.toUri on it, normally (assuming #6419926 is fixed) a file:/... URI is returned which can then be used to refer to that resource, say by passing it to an XML parser.

When however the source tree is located on a Windows UNC share (\\server\share\path\...), the returned URI is of the form

  file:////server/share/path/...

This has well-known problems documented in #4723726; namely, the normalized form is

  file:/server/share/path/...

which translates to a different (likely nonexistent) file path.

The desired form is that specified by Microsoft:

  file://server/share/path/...

(Of course other code such as XML parsers then needs to handle proper UNC URIs as well, but that is outside the scope of the compiler.)

Comments
EVALUATION Suggested fix is problematic in the case during bootstrapping, when javac must run on JDK 6. Short term fix would be to test for nio.file code with reflection; longer term fix is to wait for JDK 6, when we will bootstrap with JDK 7, and have nio.file available.
19-01-2011

SUGGESTED FIX Use java.nio.file.Path.toUri from RegularFileObject.toUri.
13-01-2010

WORK AROUND Rewrite some URIs gotten from toUri before using.
13-01-2010