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

[jira] Created: (HARMONY-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
-------------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-67
         URL: http://issues.apache.org/jira/browse/HARMONY-67
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Svetlana Samoilenko


According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
BEA does not throw any exceptions.

Code to reproduce: 
import java.nio.charset.Charset; 
import java.nio.ByteBuffer; 
import java.nio.CharBuffer; 
public class test2 {   
    public static void main(String[] args) throws Exception { 
        byte[] b = new byte[] {(byte)1}; 
        ByteBuffer buf= ByteBuffer.wrap(b); 
        CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
        System.out.println("CharBuffer.length()="+ charbuf.length());
    } 
}

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

Output: 
C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
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) 
CharBuffer.length()=0

C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
 java.nio.BufferOverflowException
        at java.nio.CharBuffer.put(CharBuffer.java:662) 
        at java.nio.CharBuffer.put(CharBuffer.java:629) 
        at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
        at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
        at java.nio.charset.Charset.decode(Charset.java:630) 
        at test2.main(test2.java:8)

Suggested junit test case:
------------------------ CharsetTest.java ------------------------------------------------- 
import java.nio.charset.Charset; 
import java.nio.ByteBuffer; 
import java.nio.CharBuffer; 

import junit.framework.*; 

public class CharsetTest extends TestCase { 
    public static void main(String[] args) { 
        junit.textui.TestRunner.run(CharsetTest.class); 
    } 
    public void test_decode() { 
        byte[] b = new byte[] {(byte)1}; 
        ByteBuffer buf= ByteBuffer.wrap(b); 
        CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
        assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
        
        charbuf=Charset.forName("UTF-16BE").decode(buf); 
        assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
        
        charbuf=Charset.forName("UTF-16LE").decode(buf); 
        assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
    
   } 
}


-- 
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] Reopened: (HARMONY-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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


> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

    Resolution: Fixed

Svetlana,

Fixed in NIO_CHAR module java.nio.charset.CharsetDecoder at repo revision 377729.

Please check that this fully resolves your problem.


> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

    Resolution: Fixed

Verified by Svetlana.
(If anyone disagrees I'm happy to reopen it)


> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

Tim Ellison commented on HARMONY-67:
------------------------------------

Svetlana, can you explain why you think the decode behavior is wrong?

The test, as written in our SVN repository, passes on Harmony code and the Sun implementation of Java.
As Vladimir wrote, this may be a compatibility issue with the BEA implementation, and I agree that our behavior is to spec.


> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

Vladimir Strigun commented on HARMONY-67:
-----------------------------------------

Looks like duplicate of Harmony-33

> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

Vladimir Strigun commented on HARMONY-67:
-----------------------------------------

I don't think that this bug should be reopened. Possibly it's another "compatibility" bug, and I'll try to explain why.
Specification of decode method says that "A newly-allocated character buffer containing the result of the decoding operation." will be returned.  Harmony implementation of decode buffer returns CharBuffer with length equal to 1. Inside resulting buffer we can see one element: "FFFD", i.e default replacement for unmappable character. In compliance with spec  Charset.decode(buffer) method invoke following line: 
     cs.newDecoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb);
So, IMO Harmony implementation is fully correspond to the spec.

> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

Posted by "Svetlana Samoilenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-67?page=comments#action_12366771 ] 

Svetlana Samoilenko commented on HARMONY-67:
--------------------------------------------

Tim, 
I agree with Vladimir,
this condition cs.newDecoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb) is correct, it is compatibility issue.

> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

Posted by "Svetlana Samoilenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-67?page=comments#action_12366450 ] 

Svetlana Samoilenko commented on HARMONY-67:
--------------------------------------------

Tim, I confirm that there is no exeption any more, but the result  of decode method  is wrong.
Harnony returns charbuf.length())==1 while BEA returns charbuf.length())==0.
If to set UTF-8 charset, the result is equal.


> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

-- 
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-67) java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException for UTF-16BE, UTF-16LE, UTF-16 charsets.

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

Tim Ellison reassigned HARMONY-67:
----------------------------------

    Assign To: Tim Ellison

> java.nio.charset.Charset.decode(ByteBuffer) throws unexpected BufferOverflowException  for UTF-16BE, UTF-16LE, UTF-16 charsets.
> -------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-67
>          URL: http://issues.apache.org/jira/browse/HARMONY-67
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for Charset.decode(ByteBuffer  b) the method must not throw any exceptions.
> The test listed below shows that there is unexpected BufferOverflowException thrown if charset name is one in the following:  UTF-16BE, UTF-16LE, UTF-16.
> BEA does not throw any exceptions.
> Code to reproduce: 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> public class test2 {   
>     public static void main(String[] args) throws Exception { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         System.out.println("CharBuffer.length()="+ charbuf.length());
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> 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) 
> CharBuffer.length()=0
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
>  java.nio.BufferOverflowException
>         at java.nio.CharBuffer.put(CharBuffer.java:662) 
>         at java.nio.CharBuffer.put(CharBuffer.java:629) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:406) 
>         at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:243) 
>         at java.nio.charset.Charset.decode(Charset.java:630) 
>         at test2.main(test2.java:8)
> Suggested junit test case:
> ------------------------ CharsetTest.java ------------------------------------------------- 
> import java.nio.charset.Charset; 
> import java.nio.ByteBuffer; 
> import java.nio.CharBuffer; 
> import junit.framework.*; 
> public class CharsetTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(CharsetTest.class); 
>     } 
>     public void test_decode() { 
>         byte[] b = new byte[] {(byte)1}; 
>         ByteBuffer buf= ByteBuffer.wrap(b); 
>         CharBuffer charbuf=Charset.forName("UTF-16").decode(buf); 
>         assertEquals("Assert 0: charset UTF-16",0,charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16BE").decode(buf); 
>         assertEquals("Assert 1: charset UTF-16BE",0, charbuf.length());        
>         
>         charbuf=Charset.forName("UTF-16LE").decode(buf); 
>         assertEquals("Assert 2: charset UTF16LE",0, charbuf.length());
>     
>    } 
> }

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