JDK-6885123 : JavaFileObject getName issues
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-09-24
  • Updated: 2014-12-12
  • Resolved: 2012-01-13
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 b74Fixed OpenJDK6Fixed
Related Reports
Relates :  
Relates :  
Description
From Peter Ahe:
The problem [with FileObject#getName()] is that when I added getName, it was accidentally
implemented by a deprecated method in BaseFileObject. This method
returns the base name, for example, "Object.class" rather than
"/usr/java/jdk/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)".

The intent was that this method would return a name which tells the
user something, but does not use an absolute path if the user didn't.

Comments
EVALUATION There's a bunch of related issues here surrounding getName and related methods, that effectively need to be addressed together. -- FileObject.getName should return a friendly name, typically as given when the FileObject was created. (primary goal) -- abstract BaseFileObject.getName() should be deleted -- BaseFileObject should have new method getBaseName or getRawName, which returns the name to be used in raw diagnostics -- is equal to file.getName for RegularFileObjects, or zipFile.getName + "(" + entryName + ")" for the family of ZipFileObjects. -- Old199 should be eliminated -- JavacFileManager.getJavacFileName and JavacFileManager.getBaseFileName should be eliminated -- all methods marked /** @deprecated see bug 6410637 */ should be examined and either deleted or the deprecation marker removed -- BaseFileObject.toString should be fixed -- either return FileObject.getName or getClass.getSimpleName + "[" + getName + "]" or similar for easier debugging -- tests should be fixed, new tests for getName should be written, including custom Windows tests (eg C:relative-path.java), new tests for filenames in diagnostics, preferably including source-in-zip files (consider reusing fm infrastructure from recent URI tests.)
24-09-2009

EVALUATION There are three conflicting uses for getName here FileObject: return a user-friendly name for a file object BaseFileObject: return the base name for a file object (c.f. File.getName()) ZipFile.getName: return the underlying File for the ZipFile
24-09-2009