You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/06/17 05:38:26 UTC

[jira] Created: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

[classlib][luni] InputStreamReader can't handle UnicodeBig encoding
-------------------------------------------------------------------

                 Key: HARMONY-4196
                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Vasily Zakharov
            Priority: Minor


Consider the following simple test:

import java.io.*;
public class Test {
    public static void main(String[] args) throws Throwable {
	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
        System.out.println("SUCCESS");
    }
}

Output on RI:

SUCCESS

Output on Harmony/IBM VM:

<no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.

Output on Harmony/DRLVM:

Uncaught exception in main:
java.io.UnsupportedEncodingException
        at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
        at Test.main(Test.java:5)

Additional investigation shows that the cause for this exception is:

java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
        at java.nio.charset.Charset.forName(Charset.java:564)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
        at Test.main(Test.java:5)

Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
So it seems the problem is not in Charset but in InputStreamReader itself.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by Charles Lee <li...@gmail.com>.
Here is the patch look like:

diff --git
modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
index 5edc277..88a8da7 100644
---
modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
+++
modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/InputStreamReaderTest.java
@@ -55,6 +55,12 @@ public class InputStreamReaderTest extends TestCase {
                 bytes = new byte[] { '\u001b', '$', 'B', '6', 'e', 'B',
'h',
                         '\u001b', '(', 'B' };
                 break;
+            case 3:
+                bytes = new byte[] { (byte) 0xff, (byte) 0xfe };
+                break;
+            case 4:
+                bytes = new byte[] { (byte) 0xfe, (byte) 0xff };
+                break;
             }
             count = bytes.length;
         }
@@ -97,6 +103,8 @@ public class InputStreamReaderTest extends TestCase {

     private InputStreamReader reader;

+    private InputStreamReader inUTF16;
+
     private final String source = "This is a test message with Unicode
character. \u4e2d\u56fd is China's name in Chinese";

     /*
@@ -246,6 +254,20 @@ public class InputStreamReaderTest extends TestCase {
         assertEquals(Charset.forName(reader2.getEncoding()), Charset
                 .forName("utf-8"));
         reader2.close();
+        try {
+            InputStream streamIn16 = new LimitedByteArrayInputStream(3);
+            inUTF16 = new InputStreamReader(streamIn16, "UnicodeLittle");
+            inUTF16.close();
+        } catch (UnsupportedEncodingException e) {
+            fail ("Should Support UnicodeLittle");
+        }
+        try {
+            InputStream streamIn16 = new LimitedByteArrayInputStream(4);
+            inUTF16 = new InputStreamReader(streamIn16, "UnicodeBig");
+            inUTF16.close();
+        } catch (UnsupportedEncodingException e) {
+            fail ("Should Support UnicodeBig");
+        }
     }

     /**
diff --git modules/nio_char/src/main/java/java/nio/charset/Charset.java
modules/nio_char/src/main/java/java/nio/charset/Charset.java
index 7b8d79d..65a2593 100644
--- modules/nio_char/src/main/java/java/nio/charset/Charset.java
+++ modules/nio_char/src/main/java/java/nio/charset/Charset.java
@@ -508,6 +508,9 @@ public abstract class Charset implements
Comparable<Charset> {
      *             If the desired charset is not supported by this runtime.
      */
     public static Charset forName(String charsetName) {
+        if ("UnicodeBig".equalsIgnoreCase(charsetName) ||
"UnicodeLittle".equalsIgnoreCase(charsetName)) {
+            charsetName = "UTF-16";
+        }
         Charset c = forNameInternal(charsetName);
         if (null == c) {
             throw new UnsupportedCharsetException(charsetName);



On Thu, Mar 5, 2009 at 2:41 PM, Li Jing Qin (JIRA) <ji...@apache.org> wrote:

>
>    [
> https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679092#action_12679092]
>
> Li Jing Qin commented on HARMONY-4196:
> --------------------------------------
>
> Hey guys, I am doing EUT test for 3.5. This also block the testcase. So I
> decide to fix it.
> I am agree with Paulex to map the UnicodeBig and UnicodeLittle to the
> UTF-16. Here is the similiar tests:
> public final static byte[] BOM_UTF_16BE = {(byte) 0xFE, (byte) 0xFF};
>
>        public static void printByteArray(byte[] array) {
>                System.out.println("LEN: " + array.length);
>                for (byte b : array) {
>                        System.out.print(Character.forDigit(((b & 0xF0) >>
> 4), 16));
>                        System.out.print(Character.forDigit((b & 0x0F),
> 16));
>                        System.out.print(" ");
>                }
>                System.out.println();
>        }
>
>        public static InputStream getInputStream(byte[][] contents) {
>                int size = 0;
>                // computes final array size
>                for (int i = 0; i < contents.length; i++)
>                        size += contents[i].length;
>                byte[] full = new byte[size];
>                int fullIndex = 0;
>                // concatenates all byte arrays
>                for (int i = 0; i < contents.length; i++)
>                        for (int j = 0; j < contents[i].length; j++)
>                                full[fullIndex++] = contents[i][j];
>                return new ByteArrayInputStream(full);
>        }
>
>        public static void main(String[] args) throws Exception {
>                String XML_ROOT_ELEMENT_NO_DECL =
> "<org.eclipse.core.runtime.tests.root-element/>";
>                try {
>                        byte[] bArray =
> XML_ROOT_ELEMENT_NO_DECL.getBytes("UTF-16BE");
>                        printByteArray(bArray);
>                } catch (Exception e) {
>                        e.printStackTrace();
>                }
>
>                InputStreamReader reader = new
> InputStreamReader(getInputStream(new byte[][] {BOM_UTF_16BE,
> XML_ROOT_ELEMENT_NO_DECL.getBytes("UTF-16BE")}), "UnicodeBig");
>                StringBuilder sb = new StringBuilder();
>                int c = -1;
>                while ((c = reader.read()) != -1) {
>                        sb.append((char)c);
>                }
>                System.out.println("GET:" + sb);
>        }
>
> if we change the "UnicodeBig" to the "UTF-16", our harmony could correctly
> parse the stream.
>
> There are two ways to fix this:
> 1. Add the mapping in the InputStreamReader and OutputStreamReader
> 2. Add the mapping in the Charset.forName(), which will let the Charset
> support UnicodeBig and UnicodeLittle.
>
> I would like to choose fix 2. Any consideration is appreciate.
> Patch will be attached later.
>
>
> > [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> > -------------------------------------------------------------------
> >
> >                 Key: HARMONY-4196
> >                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
> >             Project: Harmony
> >          Issue Type: Bug
> >          Components: Classlib
> >            Reporter: Vasily Zakharov
> >            Assignee: Alexei Zakharov
> >            Priority: Minor
> >         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
> >
> >
> > Consider the following simple test:
> > import java.io.*;
> > public class Test {
> >     public static void main(String[] args) {
> >         try {
> >             new InputStreamReader(new ByteArrayInputStream(new byte[]
> {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
> >             System.out.println("SUCCESS");
> >         } catch (Throwable e) {
> >             System.out.println("FAIL:");
> >             e.printStackTrace(System.out);
> >         }
> >     }
> > }
> > Output on RI:
> > SUCCESS
> > Output on Harmony (both DRL VM and IBM VM):
> > FAIL:
> > java.io.UnsupportedEncodingException
> >         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
> >         at Test.main(Test.java:6)
> > Additional investigation shows that the cause for this exception is:
> > java.nio.charset.UnsupportedCharsetException: The unsupported charset
> name is "UnicodeBig".
> >         at java.nio.charset.Charset.forName(Charset.java:564)
> >         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
> >         at Test.main(Test.java:5)
> > Interesting point is, the direct call to Charset.forName("UnicodeBig")
> causes the same exception on RI also.
> > So it seems the problem is not in Charset but in InputStreamReader
> itself.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
Yours sincerely,
Charles Lee

Re: [jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by Charles Lee <li...@gmail.com>.
Thanks Tim. That's the better way.

And ICU supports the "unicodebig" encoding. Try this:

Charset charset = CharsetICU.forNameICU("UnicodeBig");
System.out.println(charset);

It pass and return "UTF-16".

On Fri, May 15, 2009 at 12:54 AM, Tim Ellison (JIRA) <ji...@apache.org>wrote:

>
>    [
> https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12709466#action_12709466]
>
> Tim Ellison commented on HARMONY-4196:
> --------------------------------------
>
> I think that option (2) above is a better solution, but it depends which
> charset provider we are talking about.
>
> For the built-in provider it should be sufficient to add:
>
> Index: src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> ===================================================================
> --- src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> (revision 774723)
> +++ src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> (working copy)
> @@ -320,7 +320,9 @@
>
>             { "UTF_16",      null,new String[] { "UTF-16",
>                                                  "UTF16",
> -                                                 "UTF_16" } },
> +                                                 "UTF_16",
> +                                                 "UnicodeLittle",
> +                                                 "UnicodeBig" } },
>
>             { "UTF_16LE",    null,new String[] { "UTF-16LE",
>                                                  "X-UTF-16LE",
>
>
> But I'd have to look a bit closer to see what it takes to add an alias to
> ICU providers.
>
>
> > [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> > -------------------------------------------------------------------
> >
> >                 Key: HARMONY-4196
> >                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
> >             Project: Harmony
> >          Issue Type: Bug
> >          Components: Classlib
> >            Reporter: Vasily Zakharov
> >            Assignee: Alexei Zakharov
> >            Priority: Minor
> >         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch,
> HARMONY-4196.diff
> >
> >
> > Consider the following simple test:
> > import java.io.*;
> > public class Test {
> >     public static void main(String[] args) {
> >         try {
> >             new InputStreamReader(new ByteArrayInputStream(new byte[]
> {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
> >             System.out.println("SUCCESS");
> >         } catch (Throwable e) {
> >             System.out.println("FAIL:");
> >             e.printStackTrace(System.out);
> >         }
> >     }
> > }
> > Output on RI:
> > SUCCESS
> > Output on Harmony (both DRL VM and IBM VM):
> > FAIL:
> > java.io.UnsupportedEncodingException
> >         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
> >         at Test.main(Test.java:6)
> > Additional investigation shows that the cause for this exception is:
> > java.nio.charset.UnsupportedCharsetException: The unsupported charset
> name is "UnicodeBig".
> >         at java.nio.charset.Charset.forName(Charset.java:564)
> >         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
> >         at Test.main(Test.java:5)
> > Interesting point is, the direct call to Charset.forName("UnicodeBig")
> causes the same exception on RI also.
> > So it seems the problem is not in Charset but in InputStreamReader
> itself.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
Yours sincerely,
Charles Lee

[jira] Updated: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasily Zakharov updated HARMONY-4196:
-------------------------------------

    Attachment: Harmony-4196-InputStreamReader_diagnostics.patch

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) throws Throwable {
> 	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>         System.out.println("SUCCESS");
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony/IBM VM:
> <no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.
> Output on Harmony/DRLVM:
> Uncaught exception in main:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:5)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505575 ] 

Vasily Zakharov commented on HARMONY-4196:
------------------------------------------

This problem was discovered while investigating the HARMONY-3850 issue with Eclipse Unit Test org.eclipse.core.tests.runtime.content.IContentTypeManagerTest.testRootElementAndDTDDescriber().


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) throws Throwable {
> 	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>         System.out.println("SUCCESS");
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony/IBM VM:
> <no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.
> Output on Harmony/DRLVM:
> Uncaught exception in main:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:5)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505574 ] 

Vasily Zakharov commented on HARMONY-4196:
------------------------------------------

I also tried to patch historicalNames in InputStreamReader (lines 252-253) to replace "UnicodeBigUnmarked" with "UnicodeBig", but it changed nothing in the reproduced effects.


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) throws Throwable {
> 	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>         System.out.println("SUCCESS");
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony/IBM VM:
> <no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.
> Output on Harmony/DRLVM:
> Uncaught exception in main:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:5)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Li Jing Qin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679092#action_12679092 ] 

Li Jing Qin commented on HARMONY-4196:
--------------------------------------

Hey guys, I am doing EUT test for 3.5. This also block the testcase. So I decide to fix it.
I am agree with Paulex to map the UnicodeBig and UnicodeLittle to the UTF-16. Here is the similiar tests:
public final static byte[] BOM_UTF_16BE = {(byte) 0xFE, (byte) 0xFF};
	
	public static void printByteArray(byte[] array) {
		System.out.println("LEN: " + array.length);
		for (byte b : array) {
			System.out.print(Character.forDigit(((b & 0xF0) >> 4), 16));
			System.out.print(Character.forDigit((b & 0x0F), 16));
			System.out.print(" ");
		}
		System.out.println();
	}
	
	public static InputStream getInputStream(byte[][] contents) {
		int size = 0;
		// computes final array size 
		for (int i = 0; i < contents.length; i++)
			size += contents[i].length;
		byte[] full = new byte[size];
		int fullIndex = 0;
		// concatenates all byte arrays
		for (int i = 0; i < contents.length; i++)
			for (int j = 0; j < contents[i].length; j++)
				full[fullIndex++] = contents[i][j];
		return new ByteArrayInputStream(full);
	}
	
	public static void main(String[] args) throws Exception {
		String XML_ROOT_ELEMENT_NO_DECL = "<org.eclipse.core.runtime.tests.root-element/>";
		try {
			byte[] bArray = XML_ROOT_ELEMENT_NO_DECL.getBytes("UTF-16BE");
			printByteArray(bArray);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		InputStreamReader reader = new InputStreamReader(getInputStream(new byte[][] {BOM_UTF_16BE, XML_ROOT_ELEMENT_NO_DECL.getBytes("UTF-16BE")}), "UnicodeBig");
		StringBuilder sb = new StringBuilder();
		int c = -1;
		while ((c = reader.read()) != -1) {
			sb.append((char)c);
		}
		System.out.println("GET:" + sb);
	}

if we change the "UnicodeBig" to the "UTF-16", our harmony could correctly parse the stream.

There are two ways to fix this:
1. Add the mapping in the InputStreamReader and OutputStreamReader
2. Add the mapping in the Charset.forName(), which will let the Charset support UnicodeBig and UnicodeLittle.

I would like to choose fix 2. Any consideration is appreciate.
Patch will be attached later.


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vladimir Beliaev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553287 ] 

Vladimir Beliaev commented on HARMONY-4196:
-------------------------------------------

The bug is still reproducible on M4 snapshot:

../harmony-jdk-603534/bin/java -showversion Test
Apache Harmony Launcher : (c) Copyright 1991, 2007 The Apache Software Foundation or its licensors, as applicable.
java version "1.5.0" 
pre-alpha : not complete or compatible
svn = r603534, (Dec 13 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org
FAIL:
java.io.UnsupportedEncodingException
        at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
        at Test.main(Test.java:6)
Caused by: java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
        at java.nio.charset.Charset.forName(Charset.java:516)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
        ... 1 more

Thanks
Vladimir Beliaev

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12709466#action_12709466 ] 

Tim Ellison commented on HARMONY-4196:
--------------------------------------

I think that option (2) above is a better solution, but it depends which charset provider we are talking about.

For the built-in provider it should be sufficient to add:

Index: src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
===================================================================
--- src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java	(revision 774723)
+++ src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java	(working copy)
@@ -320,7 +320,9 @@
                                   
             { "UTF_16",      null,new String[] { "UTF-16",
                                                  "UTF16",
-                                                 "UTF_16" } },
+                                                 "UTF_16",
+                                                 "UnicodeLittle",
+                                                 "UnicodeBig" } },
                               
             { "UTF_16LE",    null,new String[] { "UTF-16LE",
                                                  "X-UTF-16LE",


But I'd have to look a bit closer to see what it takes to add an alias to ICU providers.


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch, HARMONY-4196.diff
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505573 ] 

Vasily Zakharov commented on HARMONY-4196:
------------------------------------------

To get this root cause mentioned above I had to patch InputStreamReader, and I think this small patch is good to be applied permanently, as it improves the diagnostics quality. Attached as C:\Harmony-4196-InputStreamReader_diagnostics.patch.


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) throws Throwable {
> 	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>         System.out.println("SUCCESS");
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony/IBM VM:
> <no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.
> Output on Harmony/DRLVM:
> Uncaught exception in main:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:5)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-4196:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515054 ] 

Vasily Zakharov commented on HARMONY-4196:
------------------------------------------

Great, thanks Alexei! This doesn't resolve the issue, but sure helps anyway.


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-4196:
----------------------------------------

    Assignee:     (was: Alexei Zakharov)

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch, HARMONY-4196.diff
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12515050 ] 

Alexei Zakharov commented on HARMONY-4196:
------------------------------------------

I've committed Harmony-4196-InputStreamReader_diagnostics.patch at the revision 559141. Hope this helps.

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12538003 ] 

Tim Ellison commented on HARMONY-4196:
--------------------------------------

Any more thoughts or progress on this?  It is blocking a chain of issues that would be good to get fixed.

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasily Zakharov updated HARMONY-4196:
-------------------------------------

    Description: 
Consider the following simple test:

import java.io.*;

public class Test {
    public static void main(String[] args) {
        try {
            new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
            System.out.println("SUCCESS");
        } catch (Throwable e) {
            System.out.println("FAIL:");
            e.printStackTrace(System.out);
        }
    }
}

Output on RI:

SUCCESS

Output on Harmony (both DRL VM and IBM VM):

FAIL:
java.io.UnsupportedEncodingException
        at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
        at Test.main(Test.java:6)

Additional investigation shows that the cause for this exception is:

java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
        at java.nio.charset.Charset.forName(Charset.java:564)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
        at Test.main(Test.java:5)

Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
So it seems the problem is not in Charset but in InputStreamReader itself.


  was:
Consider the following simple test:

import java.io.*;
public class Test {
    public static void main(String[] args) throws Throwable {
	new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
        System.out.println("SUCCESS");
    }
}

Output on RI:

SUCCESS

Output on Harmony/IBM VM:

<no output>, I assume the exception below is thrown but not printed out due to some problem in IBM VM.

Output on Harmony/DRLVM:

Uncaught exception in main:
java.io.UnsupportedEncodingException
        at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
        at Test.main(Test.java:5)

Additional investigation shows that the cause for this exception is:

java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
        at java.nio.charset.Charset.forName(Charset.java:564)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
        at Test.main(Test.java:5)

Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
So it seems the problem is not in Charset but in InputStreamReader itself.



> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519889 ] 

Paulex Yang commented on HARMONY-4196:
--------------------------------------

It's yet another historical/canonical encoding issue in Java platform,
java.io/lang has old/non-standard canonical name with Unicode as well as
java.nio, here's a link on the mapping for Java SE 5:[1] , and here's for
Java SE 6:[2]

The difference between "UnicodeBIg" and "UnicodeBigUnmarked"(i.e., UTF-16BE)
is, according to the explanation on the tables[1][2], is the UnicodeBig has
BOM("0xFEFF" for big endian). The difference applies to UnicodeLittle and
UnicodeLittleUnmarked, too.

My suggestion is to just map the "UnicodeBig" and "UnicodeLittle" to
"utf-16" in InputStreamReader and OutputStreamWriter's constructors, because
utf-16 can recognize the BOM and adapt to the byte stream accordingly. We
may also need to map other java.io canonical name to java.nio name(currently
there's only a reverse map for this) accordingly.  I haven't tested if it is
necessarythough.

[1]http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
[2]http://java.sun.com/javase/6/docs/technotes/guides/intl/encoding.doc.html.



-- 
Paulex Yang
China Software Development laboratory
IBM


> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4196) [classlib][luni] InputStreamReader can't handle UnicodeBig encoding

Posted by "Li Jing Qin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Li Jing Qin updated HARMONY-4196:
---------------------------------

    Attachment: HARMONY-4196.diff

> [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> -------------------------------------------------------------------
>
>                 Key: HARMONY-4196
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4196
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>            Assignee: Alexei Zakharov
>            Priority: Minor
>         Attachments: Harmony-4196-InputStreamReader_diagnostics.patch, HARMONY-4196.diff
>
>
> Consider the following simple test:
> import java.io.*;
> public class Test {
>     public static void main(String[] args) {
>         try {
>             new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
>             System.out.println("SUCCESS");
>         } catch (Throwable e) {
>             System.out.println("FAIL:");
>             e.printStackTrace(System.out);
>         }
>     }
> }
> Output on RI:
> SUCCESS
> Output on Harmony (both DRL VM and IBM VM):
> FAIL:
> java.io.UnsupportedEncodingException
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
>         at Test.main(Test.java:6)
> Additional investigation shows that the cause for this exception is:
> java.nio.charset.UnsupportedCharsetException: The unsupported charset name is "UnicodeBig".
>         at java.nio.charset.Charset.forName(Charset.java:564)
>         at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
>         at Test.main(Test.java:5)
> Interesting point is, the direct call to Charset.forName("UnicodeBig") causes the same exception on RI also.
> So it seems the problem is not in Charset but in InputStreamReader itself.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.