Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-1360

[classlib][nio charset] Charset.forName() returns different value vs Charset.availableCharsets()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      The spec says for the method Charset.availableCharsets(): "In the absence of such changes (dynamically load of new charset providers), the charsets returned by this method are exactly those that can be retrieved via the forName method.
      It works on RI but fails on Harmony.

      ================= test.java =======================
      import java.util.SortedMap;
      import java.nio.charset.Charset;

      public class test {
      public static void main(String args[]) {
      SortedMap allCharsets = Charset.availableCharsets();
      Object[] names = allCharsets.keySet().toArray();

      for (int i = 0; i < names.length; ++i){
      Charset _chset = (Charset) allCharsets.get(names[i]);
      Charset chset = Charset.forName((String) names[i]);
      if (!chset.name().equals(_chset.name()))

      { System.out.println("forName(" + names[i] + ") returned '" + chset + "', instead of '" + _chset + "'"); }

      }
      System.out.println("END");
      }
      }
      ===============================================

      Output:
      C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp . -showversion test
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))

      END

      C:\tmp\tmp17>C:\harmony\classlib1.5\deploy\jdk\jre\bin\java.exe -cp . -showversion test
      java version 1.5 (subset)

      (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
      forName(KSC_5601) returned 'Charset[EUC-KR]', instead of 'Charset[KSC_5601]'
      END

        Attachments

        1. CharsetTest.patch
          1 kB
          Vladimir Ivanov

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vladimir Vladimir Ivanov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: