Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4023102

(i18n) Class.forName doesn't work with a non-ASCII name

XMLWordPrintable

    • generic, sparc
    • generic, solaris_2.5.1, solaris_9


      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)

            apalanissunw Anand Palaniswamy (Inactive)
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: