Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 95124 invoked from network); 27 Jan 2006 10:54:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Jan 2006 10:54:11 -0000 Received: (qmail 67916 invoked by uid 500); 27 Jan 2006 10:54:07 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 67567 invoked by uid 500); 27 Jan 2006 10:54:06 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 67556 invoked by uid 99); 27 Jan 2006 10:54:06 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2006 02:54:04 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 44FADC9 for ; Fri, 27 Jan 2006 11:53:43 +0100 (CET) Message-ID: <576266031.1138359222876.JavaMail.jira@ajax.apache.org> Date: Fri, 27 Jan 2006 11:53:42 +0100 (CET) From: "Vladimir Strigun (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Commented: (HARMONY-52) java.io.ByteArrayOutputStream.toString(String) throws IllegalCharsetNameException instead of UnsupportedEncodingException In-Reply-To: <172036312.1138355320027.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ 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