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

wrong conversion using in jni GetStringUTFChars() for japanese sjis or PCK code

XMLWordPrintable

      Fujitsu has provided a jni testcase for java 1.2 which doesn't show Japanese SJIS codes
      3rd. argument of icv.convertExtended() in convertEx.java is sjis.

      I can find in 4642283 Suggested Fix
      + classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);

      This is the use of the function in convertEx.c from the testcase provided by Fujitsu
       srcString = (char *)((*env)->GetStringUTFChars(env, strSrc, NULL));
       fromCode = (char *)((*env)->GetStringUTFChars(env, strFrom, NULL));
       toCode = (char *)((*env)->GetStringUTFChars(env, strTo, NULL));
       printf("TEST convertExtended fromCode[%s] toCode[%s]\n",fromCode,toCode);

      Testcase has been checked in Sun with Sol8/9 and java 1.2.2_10 and 1.4.1_02
      We can see japanese characters in convertEx.java in the call to the jni function icv.convertExtended (using dtpad and gedit)

      % java -version
      java version "1.2.2"
      Solaris VM (build Solaris_JDK_1.2.2_10, native threads, sunwjit)
      % javac convertEx.java
      % javah -jni convertEx
      % cc -V
      cc: Forte Developer 7 C 5.4 2002/03/09
      % cc -G -I.
      -I/usr/java1.2/include -I/usr/java1.2/include/solaris convertEx.c -o libconvertEx.so
      "convertEx.c", line 78: warning: argument #2 is incompatible with
      prototype:
              prototype: pointer to pointer to const char : "/usr/include/iconv.h", line 20
              argument : pointer to pointer to char
      % java -Djava.library.path=. convertEx UTF-8 PCK
      ***** start
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [abcdefg]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [????A~^(o)U?N??]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?????????}]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING
      [?@?A?B?C?D?E?F?G?H?I?_?`?a?b?c?d?e?f?g?h?i?j?k?l?m?n]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [???????????????????]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?o?p?q?r]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING
      [??????}?????L???A~????????????????@?A?B?C?D?E?F?G?H?I?J?K?L?M?N]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?@?A?B?C?D?E?F?G?H?I?J?K?L?M?N]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?????????????A~^(o)U]
      ***** end [?????????????U]

      % /usr/j2se/bin/java -version
      java version "1.4.1_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
      Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
      % /usr/j2se/bin/java -Djava.library.path=. convertEx UTF-8 PCK
      ***** start
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [abcdefg]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [????A~^(o)U?N??]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?????????}]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING
      [?@?A?B?C?D?E?F?G?H?I?_?`?a?b?c?d?e?f?g?h?i?j?k?l?m?n]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [???????????????????]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?o?p?q?r]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING
      [??????}?????L???A~????????????????@?A?B?C?D?E?F?G?H?I?J?K?L?M?N]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?@?A?B?C?D?E?F?G?H?I?J?K?L?M?N]
      TEST convertExtended fromCode[UTF-8] toCode[PCK]
      TEST convertExtended CALLING [?????????????A~^(o)U]
      ***** end [??????????????????U]

      ###@###.### 2003-06-25
      see also original sjis code in attachment (kanji.gif)

            chegar Chris Hegarty
            cmassi Claudio Massi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: