[Patch] 6502392 Invalid relative names for Filer.createResource and Filer.getResource

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Mon Jan 5 17:11:22 PST 2009


Emil,

Thank you for looking at this, and for your patch.

I do not understand why 6419701 is not public. I am trying to find out 
why it is not.
The bug itself is about the use of URI.create, not about the use of 
isRelativeURI.

I'm not sure that your patch is warranted (or arguably, the correct 
fix).  Your patch certainly
contains functionality that on the face of it would better belong in 
java.net.URI and not
JavacFileManager.

The way I read the code in JavacFileManager, isRelativeURI is not 
intended to be a full and
complete implementation of checking whether a URI is path-rootless. 
Instead, it is used in
exactly 3 places, and always in conjunction with URI.create.  
JavacFileManager is assuming
the full syntax checking is done by URI.create, and is just using a 
simple impl of
isRelativeURI to distinguish relative URIs from absolute URIs created by 
URI.create.

6419701 is about removing the use of URI.create -- presumably because it 
is mildly icky
to create the URI object just to check whether a path string is a valid 
URI.  So it seems
to me that there are two ways to take this issue: 
1) Rewrite isRelativeURI to take a String argument and thereby avoid the 
use of URI.create
2) Wait for URI to have some better method for checking the validity of 
a path without
actually constructing the URI object.

I guess that I dislike JavacFileManager having code for detailed parsing 
of URIs, and so
I think the current impl is better, of using URI.create to check the 
syntax of a URI, and
then apply a quick check as to whether it is absolute or relative is better.

Or am I misreading the situation or perhaps missing some subtlety in 
your proposed code?

-- Jon


Emil Andreas Siemes wrote:
> com.sun.tools.javac.file.JavacFileManager checks if a name fulfills 
> the requirements of relative names:
> "A relative name is a non-null, non-empty sequence of path segments 
> separated by |'/'|; |'.'| and |'..'| are invalid path segments. A 
> valid relative name must match the "path-rootless" rule of RFC 3986 
> <http://www.ietf.org/rfc/rfc3986.txt>, section 3.3."
>
> This is done via the isRelativeUri() method. Unfortunately this method 
> doesn't currently really check for path-rootless compliance. A patch 
> with an improved method is attached.
> When java.net.Uri eventually supports RFC 3986 the need for 
> isRelativeUri() goes away. I would also like to propose to rename 
> isRelativeUri() to isRF3986PathRootless() which would more clearly 
> describe what the method does.
>
> There is a comment in JavacFileManager in a couple of lines:
> //FIX ME 6419701
> but I don't find bug 6419701 in the bug database. Any thoughts?
>
> Thanks
>     Emil
>
>
>
>
>  
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20090105/0db5ce8a/attachment.html 


More information about the compiler-dev mailing list