You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Vladimir Ivanov (JIRA)" <ji...@apache.org> on 2006/01/27 10:48:40 UTC

[jira] Created: (HARMONY-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException

java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 
--------------------------------------------------------------------------------------------------------------------------

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


java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 

j2se 1.4.2 and 1.5.0 says, that method java.io.ByteArrayOutputStream.toString(String)
 throws UnsupportedEncodingException, if the named encoding is not supported.

Code to reproduce:
import java.io.*; 
  
public class test29 { 
    public static void main(String[] args)  {
	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
        try { 
	    os.write("ababa".getBytes()); 
            os.toString("this is the name \n of a nonexistent encoding" 
                    + Math.random()); 
        } catch(UnsupportedEncodingException e) { 
            System.out.println("PASSED"); 
        } catch(Exception e) { 
            System.out.println("FAILED: " + e); 
        } 
   } 
}  

Steps to Reproduce: 
1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
2. Compile test29.java using BEA 1.4 javac 
> javac -d . test29.java 
3. Run java using compatible VM (J9) 
> java -showversion test29


Output:
C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
Native Threads, GC strategy: parallel)

PASSED

C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
java version 1.4.2 (subset)

(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as app
licable.
FAILED: java.nio.charset.IllegalCharsetNameException: The illegal charset name i
s "this is the name
 of a nonexistent encoding0.4487506282752648".

C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)

PASSED

C:\tmp\tmp17>

junit test:
------------------------ ByteArrayOutputStreamTest.java -------------------------------------------------
import java.io.*; 

import junit.framework.*; 
  
public class ByteArrayOutputStreamTest extends TestCase { 
    public static void main(String[] args) { 
        junit.textui.TestRunner.run(ByteArrayOutputStreamTest.class); 
    } 

    public void testToString_String() { 
	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
        try { 
	    os.write("ababa".getBytes()); 
            os.toString("this is the name \n of a nonexistent encoding" 
                    + Math.random()); 
        } catch(UnsupportedEncodingException e) { 
        } catch(Exception e) { 
            fail("Unexpected exception: " + e); 
        } 
    }
} 


-- 
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-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException

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

Tim Ellison reassigned HARMONY-52:
----------------------------------

    Assign To: Tim Ellison

> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException
> -------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-52
>          URL: http://issues.apache.org/jira/browse/HARMONY-52
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison

>
> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 
> j2se 1.4.2 and 1.5.0 says, that method java.io.ByteArrayOutputStream.toString(String)
>  throws UnsupportedEncodingException, if the named encoding is not supported.
> Code to reproduce:
> import java.io.*; 
>   
> public class test29 { 
>     public static void main(String[] args)  {
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>             System.out.println("PASSED"); 
>         } catch(Exception e) { 
>             System.out.println("FAILED: " + e); 
>         } 
>    } 
> }  
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
> 2. Compile test29.java using BEA 1.4 javac 
> > javac -d . test29.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test29
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
> Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
> java version 1.4.2 (subset)
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as app
> licable.
> FAILED: java.nio.charset.IllegalCharsetNameException: The illegal charset name i
> s "this is the name
>  of a nonexistent encoding0.4487506282752648".
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>
> junit test:
> ------------------------ ByteArrayOutputStreamTest.java -------------------------------------------------
> import java.io.*; 
> import junit.framework.*; 
>   
> public class ByteArrayOutputStreamTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(ByteArrayOutputStreamTest.class); 
>     } 
>     public void testToString_String() { 
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>         } catch(Exception e) { 
>             fail("Unexpected exception: " + e); 
>         } 
>     }
> } 

-- 
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-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException

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

Tim Ellison updated HARMONY-52:
-------------------------------

    Attachment: StringTest.java

Attaching JUnit testcase so I don't loose it.

> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException
> -------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-52
>          URL: http://issues.apache.org/jira/browse/HARMONY-52
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison
>  Attachments: StringTest.java
>
> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 
> j2se 1.4.2 and 1.5.0 says, that method java.io.ByteArrayOutputStream.toString(String)
>  throws UnsupportedEncodingException, if the named encoding is not supported.
> Code to reproduce:
> import java.io.*; 
>   
> public class test29 { 
>     public static void main(String[] args)  {
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>             System.out.println("PASSED"); 
>         } catch(Exception e) { 
>             System.out.println("FAILED: " + e); 
>         } 
>    } 
> }  
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
> 2. Compile test29.java using BEA 1.4 javac 
> > javac -d . test29.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test29
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
> Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
> java version 1.4.2 (subset)
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as app
> licable.
> FAILED: java.nio.charset.IllegalCharsetNameException: The illegal charset name i
> s "this is the name
>  of a nonexistent encoding0.4487506282752648".
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>
> junit test:
> ------------------------ ByteArrayOutputStreamTest.java -------------------------------------------------
> import java.io.*; 
> import junit.framework.*; 
>   
> public class ByteArrayOutputStreamTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(ByteArrayOutputStreamTest.class); 
>     } 
>     public void testToString_String() { 
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>         } catch(Exception e) { 
>             fail("Unexpected exception: " + e); 
>         } 
>     }
> } 

-- 
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-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException

Posted by "Vladimir Strigun (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-52?page=comments#action_12364201 ] 

Vladimir Strigun commented on HARMONY-52:
-----------------------------------------

Ive found small testcase for the issue:
    public static void main(String[] args) throws Exception{
        byte[] arr = {'a', 'b', 'c'};
        new String(arr, 0, 2, "some charset");
    }

The behaviour of this test is the same as original. But charset name "some charset" is illegal because only following letters are allowed in charset names:
"
The uppercase letters 'A' through 'Z' ('\u0041' through '\u005a'), 
The lowercase letters 'a' through 'z' ('\u0061' through '\u007a'), 
The digits '0' through '9' ('\u0030' through '\u0039'), 
The dash character '-' ('\u002d', HYPHEN-MINUS), 
The period character '.' ('\u002e', FULL STOP), 
The colon character ':' ('\u003a', COLON), and 
The underscore character '_' ('\u005f', LOW LINE). 
"

So, if we pass to String(byte[], int, int, String) constructor  illegal charset name, it should anyway throws UnsupportedEncodingException, not IllegalCharsetNameException .

> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException
> -------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-52
>          URL: http://issues.apache.org/jira/browse/HARMONY-52
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Ivanov

>
> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 
> j2se 1.4.2 and 1.5.0 says, that method java.io.ByteArrayOutputStream.toString(String)
>  throws UnsupportedEncodingException, if the named encoding is not supported.
> Code to reproduce:
> import java.io.*; 
>   
> public class test29 { 
>     public static void main(String[] args)  {
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>             System.out.println("PASSED"); 
>         } catch(Exception e) { 
>             System.out.println("FAILED: " + e); 
>         } 
>    } 
> }  
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
> 2. Compile test29.java using BEA 1.4 javac 
> > javac -d . test29.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test29
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
> Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
> java version 1.4.2 (subset)
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as app
> licable.
> FAILED: java.nio.charset.IllegalCharsetNameException: The illegal charset name i
> s "this is the name
>  of a nonexistent encoding0.4487506282752648".
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>
> junit test:
> ------------------------ ByteArrayOutputStreamTest.java -------------------------------------------------
> import java.io.*; 
> import junit.framework.*; 
>   
> public class ByteArrayOutputStreamTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(ByteArrayOutputStreamTest.class); 
>     } 
>     public void testToString_String() { 
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>         } catch(Exception e) { 
>             fail("Unexpected exception: " + e); 
>         } 
>     }
> } 

-- 
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-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-52?page=comments#action_12364559 ] 

Tim Ellison commented on HARMONY-52:
------------------------------------

This bug is in the String implementation in the KERNEL module.  As you may know, the KERNEL module is VM-specific, which means that the bug needs fixing in the IBM download.  I'll raise a bug against that code.

However, looking at String, there is a good argument to make for taking that out of KERNEL and moving it into LUNI.  The only VM-specific part I see is the implementation of String#intern() (which is required to intern to the same table as the class constants).  I propose we move String from KERNEL to LUNI and extend the KERNEL to have a VM#intern(String) method.  This will require a matching update to J9's KERNEL and LUNI.


> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException
> -------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-52
>          URL: http://issues.apache.org/jira/browse/HARMONY-52
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison

>
> java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException 
> j2se 1.4.2 and 1.5.0 says, that method java.io.ByteArrayOutputStream.toString(String)
>  throws UnsupportedEncodingException, if the named encoding is not supported.
> Code to reproduce:
> import java.io.*; 
>   
> public class test29 { 
>     public static void main(String[] args)  {
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>             System.out.println("PASSED"); 
>         } catch(Exception e) { 
>             System.out.println("FAILED: " + e); 
>         } 
>    } 
> }  
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
> 2. Compile test29.java using BEA 1.4 javac 
> > javac -d . test29.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test29
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
> Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
> java version 1.4.2 (subset)
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as app
> licable.
> FAILED: java.nio.charset.IllegalCharsetNameException: The illegal charset name i
> s "this is the name
>  of a nonexistent encoding0.4487506282752648".
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)
> PASSED
> C:\tmp\tmp17>
> junit test:
> ------------------------ ByteArrayOutputStreamTest.java -------------------------------------------------
> import java.io.*; 
> import junit.framework.*; 
>   
> public class ByteArrayOutputStreamTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(ByteArrayOutputStreamTest.class); 
>     } 
>     public void testToString_String() { 
> 	ByteArrayOutputStream os = new ByteArrayOutputStream(); 
>         try { 
> 	    os.write("ababa".getBytes()); 
>             os.toString("this is the name \n of a nonexistent encoding" 
>                     + Math.random()); 
>         } catch(UnsupportedEncodingException e) { 
>         } catch(Exception e) { 
>             fail("Unexpected exception: " + e); 
>         } 
>     }
> } 

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