JDK-6999891 : DefaultFileManager incorrect
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u22
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2010-11-13
  • Updated: 2012-03-20
  • Resolved: 2011-03-08
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 7 Other
7 b126Fixed OpenJDK6Fixed
Related Reports
Relates :  
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 http://hg.openjdk.java.net/jdk7/build/langtools/rev/0141f508b98d
17-01-2011

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.
06-12-2010