United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6999891 DefaultFileManager incorrect
JDK-6999891 : DefaultFileManager incorrect

Details
Type:
Bug
Submit Date:
2010-11-13
Status:
Closed
Updated Date:
2012-03-20
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
tools
OS:
windows_7
Sub-Component:
javac
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u22
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Wersja 6.1.7600]

A DESCRIPTION OF THE PROBLEM :
The bug appears when trying to create resource with filename '.' from annotation processor level. Folllowing line:

processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "foo", ".foo2", element)

throws Exception:

java.lang.IllegalArgumentException: relativeName is invalid
	at com.sun.tools.javac.util.DefaultFileManager.getFileForOutput(DefaultFileManager.java:1050)

In spec it is said:
"A relative name is a non-null, non-empty sequence of path segments separated by '/'.; '.' or '..' are invalid path segments."

But in that case '.' at the begining of filename is not the segment. There is a difference between ".foo2" and "./foo2". The first one seems to be correct filename. But I cannot create it with DefaultFileManager. There is no way to create resource starting with '.' character.


REPRODUCIBILITY :
This bug can be reproduced always.

                                    

Comments
EVALUATION

The spec is confusing and could bre rephrased more clearly.

The submitter correctly quotes the spec as saying: 

"A relative name is a non-null, non-empty sequence of path segments separated by '/'; '.' and '..' are invalid path segments"

Even though it is sometime correct in English to use semicolon as a list separator, that does not apply here, so the correct reading is:

(1) A relative name is a non-null, non-empty sequence of path segments separated by '/'.
(2) '.' and '..' are invalid path segments

Thus .foo2 should be accepted as a valid relativeName.
                                     
2010-12-06
EVALUATION

http://hg.openjdk.java.net/jdk7/build/langtools/rev/0141f508b98d
                                     
2011-01-17



Hardware and Software, Engineered to Work Together