JDK-4421728 : Specification required for mapping from class names to file names
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version:
    1.0.2,1.1,1.1.3,1.1.6,1.1.8,1.2.0,1.2.1,1.2.2,1.3.0,1.4.0,1.4.2,5.0,6u26 1.0.2,1.1,1.1.3,1.1.6,1.1.8,1.2.0,1.2.1,1.2.2,1.3.0,1.4.0,1.4.2,5.0,6u26
  • Priority: P4
  • Status: Closed
  • Resolution: Future Project
  • OS:
    generic,solaris_2.6,solaris_7,solaris_8,windows_95,windows_98,windows_nt,windows_2000,windows_7 generic,solaris_2.6,solaris_7,solaris_8,windows_95,windows_98,windows_nt,windows_2000,windows_7
  • CPU: generic,x86,sparc
  • Submitted: 2001-03-05
  • Updated: 2015-01-07
  • Resolved: 2007-01-10
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
To "write once run anywhere" it is necessary to have a defined mapping from
class name to the file name that will contain the class. The absence of a
strategy to address this issue results in unresolveable bugs and
interoperability failure on all platforms.

The mapping needs to be specified, rather than a choice of the implementation, in order for implementations on the same platform to be interoperable.

Some examples of the problems that need to be solved by a platform-specific specfication of the class name to file name mapping:

(1)	Win32 and liks platforms are not case sensitive, while Java
	identifiers are.
(2)	The unix limit on the total length of a filename is much
	shorter than the limit on the length of a qualified Java identifier.
(3)	Java identifiers include unicode characters; none of the target
	file systems do.

A further problem arises because the tools we provide to produce jar files
may have to be aware of this mapping to undo it.

Here is a sample program which the available specifications do not
give enough information to tell a compiler how to behave:

frog$ cat -n T.java
     1	/** doc for T */
     2	public class T {
     3	    /** doc for id\u0ca0\u0ca1 */
     4	    public static class id\u0ca0\u0ca1 {
     5		public void f() {}
     6	    }
     7	    /** doc for id\u0ca1\u0ca0 */
     8	    public static class id\u0ca1\u0ca0 {
     9		public void g() {}
    10	    }
    11	    public static void main(String[] args) {
    12		new id\u0ca0\u0ca1().f();
    13		new id\u0ca1\u0ca0().g();
    14	    }
    15	}
frog$ 

One suggestion would be to use a cryptographically strong hash function to 
hash the class name to 256 bits and encode those bits to a filename that
is acceptable on all platforms.

neal.gafter@Eng 2001-03-05

Comments
EVALUATION Deferring this CR as it has no chance of being solved anytime soon. As noted elsewhere, a compilation spec is required.
10-01-2007

EVALUATION I don't think this is something we can realistically solve. Platforms evolve, new ones appear etc. The notion of file itself may be missing on some platforms, or some implementations may choose not to use it - and rightly so. ###@###.### 2004-06-21
21-06-2004