JDK-4023102 : (i18n) Class.forName doesn't work with a non-ASCII name
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: solaris_2.6,1.1,1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_2.5.1,solaris_9
  • CPU: generic,sparc
  • Submitted: 1996-12-20
  • Updated: 1998-07-01
  • Resolved: 1998-07-01
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
masayoshi.okutsu@Eng 1996-12-20
Class.forName() doesn't work with a non-ASCII character name.

To reproduce, run the following:

Source program:

	// no.1
	public class classmini1{
	    public static void main(String args[]){
	        String className = "\u6f22\u5b57";
	        String  classToString = "class "+className;
	        \u6f22\u5b57 kanjiClass = new \u6f22\u5b57();
	        Class   c = kanjiClass.getClass();
	    }
	}
	//
	class \u6f22\u5b57{
	    public \u6f22\u5b57(){}
	    public static void kanjitest(){}
	}


	// no.2
	public class classmini2{
	    public static void main(String args[]){
	        String className = "\u6f22\u5b57";
	        try{
	            Class   c = Class.forName(className);
	        }
	        catch(ClassNotFoundException e){
	            e.printStackTrace();
	        }
	    }
	}
	//
	class \u6f22\u5b57{
	    public \u6f22\u5b57(){}
	    public static void kanjitest(){}
	}


Execution:

	// no.1

	% java classmini1
	java.lang.NoClassDefFoundError: ???����?����
	        at sun.io.CharToByteJIS0208.<clinit>(CharToByteJIS0208.java:33)


	// no.2
	% java classmini2
	java.lang.IllegalArgumentException: "W
	        at classmini2.main(classmini2.java:5)

Comments
EVALUATION [saraiya 1/21/97] The problem has been partially fixed, as part of the changes detailed in 4023100. However, we still have a major issue in terms of the mapping of Unicode names to file systems that don't support Unicode (eg, Solaris). For example, I can name a class with a Unicode name but the .class file on disk will have a name consisting of just the low byte of each unicode character. The mapping of Unicode names to file system names needs more thought. One approach is to make JAR files maintain UTF8 names -- thus creating a portable file-system-independent container for .class files. However, this will involve changes to jartool which are not possible in the 1.1 timeframe.
11-06-2004

WORK AROUND
11-06-2004

SUGGESTED FIX
11-06-2004

PUBLIC COMMENTS Class.forName doesn't work with a non-ASCII name
10-06-2004