Harmony
  1. Harmony
  2. HARMONY-1111

[classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

    Details

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

      Description

      The Harmony method java.lang.String(byte[] bytes, int offset, int length, String charsetName) throws IllegalArgumentException while RI creates object.

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

      public class test {
      public static void main (String [] args) throws Exception {
      byte [] b = new byte[256];
      for (int i = 0; i < b.length; i++)

      { b[i] = (byte)i; }

      System.out.println("res = " + new String(b, 170, 30, Charset.forName("UTF-8").name()));
      }
      }
      ==================================================

      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))

      res = ??????????????????????????????

      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.
      Exception in thread "main" java.lang.IllegalArgumentException: The length must be positive.
      at java.nio.charset.CoderResult.malformedForLength(CoderResult.java:152)
      at com.ibm.icu4jni.charset.CharsetDecoderICU.implFlush(Unknown Source)
      at java.nio.charset.CharsetDecoder.flush(CharsetDecoder.java:571)
      at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:254)
      at java.nio.charset.Charset.decode(Charset.java:690)
      at java.lang.String.<init>(String.java:352)
      at test.main(test.java:9)

      1. CoderResult.patch
        0.6 kB
        Vladimir Ivanov
      2. String.patch
        0.9 kB
        Vladimir Ivanov
      3. String2Test.patch
        1.0 kB
        Vladimir Ivanov

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Mark Hindess
            Reporter:
            Vladimir Ivanov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development