You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vladimir Ivanov (JIRA)" <ji...@apache.org> on 2006/08/09 11:18:13 UTC

[jira] Created: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

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

                 Key: HARMONY-1111
                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Vladimir Ivanov


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)


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Vladimir Ivanov updated HARMONY-1111:
-------------------------------------

    Attachment: CoderResult.patch

patch

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Attachments: CoderResult.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Vladimir Ivanov updated HARMONY-1111:
-------------------------------------

    Attachment: String.patch

updated patch.
Now this constructor returns '0x3f' for bytes 0xC0-0xFF. May be it should be changed to '0x1a'

Output on fixed version:
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))

0x3f
0x3f
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.
0x1a
0x3f

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch, String.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1111?page=comments#action_12431221 ] 
            
Mark Hindess commented on HARMONY-1111:
---------------------------------------

I don't think this is the correct fix.  With this fix, the following line of code:

  java.nio.charset.CoderResult.malformedForLength(0)

no longer throws an IllegalArgumentException even though the RI does throw such an exception.


> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Vladimir Ivanov updated HARMONY-1111:
-------------------------------------

    Attachment: String2Test.patch

unit test

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch, String.patch, String2Test.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Assigned: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Mark Hindess reassigned HARMONY-1111:
-------------------------------------

    Assignee: Mark Hindess

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Mark Hindess closed HARMONY-1111.
---------------------------------


Verified by Vladimir.


> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch, String.patch, String2Test.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1111?page=comments#action_12431223 ] 
            
Vladimir Ivanov commented on HARMONY-1111:
------------------------------------------

I'll see on it.

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1111?page=comments#action_12446803 ] 
            
Vladimir Ivanov commented on HARMONY-1111:
------------------------------------------

verified, thanks

> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch, String.patch, String2Test.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1111?page=comments#action_12431524 ] 
            
Vladimir Ivanov commented on HARMONY-1111:
------------------------------------------

The root reason of this issue is different behavior RI vs Harmony to decode bytes from the range 0xC0-0xFF (according to the JVMS it is 2 and 3 bytes symbols in the UTF-8 strings).
According to the API spec for this constructor:
"The behavior of this constructor when the given bytes are not valid in the given charset is unspecified"

So, for invalid array of bytes RI returns '0x3f' while Harmony returns '0x1a' or throws exception.
Proposed patch is invalid. Seems, the String constructor should be fixed.

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

public class test { 
    public static void main (String [] args) throws Exception { 
	byte[] b = {(byte)0xBF};
        String str = new String(b, 0, 1, Charset.forName("UTF-8").name());
	b = str.getBytes();
        System.out.print("0x"); 
	for (int i = 0; i < b.length; i++) {
            System.out.print(Integer.toHexString(b[i]));
        }
        System.out.println("");
	byte[] b1 = {(byte)0xC0};
        str = new String(b1, 0, 1, Charset.forName("UTF-8").name());
	b1 = str.getBytes();
        System.out.print("0x"); 
	for (int i = 0; i < b1.length; i++) {
            System.out.print(Integer.toHexString(b1[i]));
        }
    } 
} 
========================================

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

0x3f
0x3f
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.
0x1a
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:727)
        at java.lang.String.<init>(String.java:361)
        at test.main(test.java:14)


> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (HARMONY-1111) [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1111?page=all ]

Mark Hindess resolved HARMONY-1111.
-----------------------------------

    Resolution: Fixed

Applied in r470381.  Please confirm it has been applied as expected.


> [classlib][lang] unexpected IllegalArgumentException for String(byte[], int, int, String)
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1111
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1111
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Assigned To: Mark Hindess
>         Attachments: CoderResult.patch, String.patch, String2Test.patch
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira