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

Collator.getInstance() causes an ArrayIndexOutofBoundsException for Korean

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • sparc
    • solaris_2.5

      A sample program:
          Collator c = Collator.getInstance();
      causes an ArrayIndexOutofBoundsException on the Korean machine.
      Using Collator.getAvailableLocales() shows that "ko" is an available locale/

      We currently are testing on approx. 10 different languages (a mix of SBCS and
      DBCS) and Korean is the only language that causes this problem.
      To test further, I ran my sample program on a Japanese machine and everything
      worked fine. I used the following code on the same Japanese machine:

      Locale.setDefault(Locale.KOREAN);
      System.out.println("New default locale: " + Locale.getDefault());
      Collator c =3D Collator.getInstance();

      This is the output:

      New default locale: ko
      java.lang.ArrayIndexOutOfBoundsException: -32768
           at java.text.CompactIntArray.compact(CompactIntArray.java:180)
           at java.text.RuleBasedCollator.build(RuleBasedCollator.java:546)

      If I run the same sample code on my English NT machine, I get the same
      exact errors. If I change the locale (.setDefault(Locale.JAPANESE) and =
      run this
      on my English machine (or Korean machine), everything works fine.

      The actual test case is:

      import java.text.*;
      import java.util.*;

      public class Test
      {
       public static void main(String[] args)
       {
                      Locale.setDefault(Locale.KOREAN);
        System.out.println("New default locale: " + Locale.getDefault());
        Collator c =3D Collator.getInstance();
        Collator c =3D Collator.getInstance();
       }
      }

      This produces an ArrayIndexOutOfBoundsException when the locale is set =
      to be
      Korean but works with other locales!

            lwernersunw Laura Werner (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: