harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2467) [classlib][nio charset] java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE) does not throw IllegalArgumentException
Date Tue, 13 Feb 2007 13:58:06 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-2467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472658
] 

Mikhail Markov commented on HARMONY-2467:
-----------------------------------------

Alexei, i think you've been misleading by the name for maxCharsPerByte() function :-).
Actually, the API spe says: "Returns the maximum number of characters that will be produced
for each byte of input.", i.e. 1 byte in the incoming ByteBuffer of coded characters will
produce maximum X characters.
See http://www.unicode.org/reports/tr6/#Examples as an examples of compressing.


> [classlib][nio charset] java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE)
does not throw IllegalArgumentException
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2467
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2467
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Anton Ivanov
>         Assigned To: Alexei Zakharov
>            Priority: Minor
>         Attachments: H-2467.patch
>
>
> According to the specification constructor must throw IllegalArgumentException if the
preconditions on the parameters do not hold.
> java.nio.charset.CharsetDecoder(cs, Float.MIN_VALUE,Float.MIN_VALUE) does not throw IllegalArgumentException
while RI does with message:
>    java.lang.IllegalArgumentException: Replacement too long
> Test to reproduce the problem:
> import junit.framework.TestCase;
> import java.nio.charset.*;
> import java.nio.*;
> public class test10036 extends TestCase {     
>     public void test1 () { 
>         try {                              
>             CharsetDecoderImpl obj = new CharsetDecoderImpl(Charset.forName("UTF-8"),
>                     Float.MIN_VALUE , Float.MIN_VALUE );   
>             fail("IllegalArgumentException should be thrown");                 
>         } catch (IllegalArgumentException e) { 
>             //expected
>         }        
>     }
> }
> class CharsetDecoderImpl extends CharsetDecoder{
>     public CharsetDecoderImpl(Charset cs, float averageBytesPerChar,
>             float maxBytesPerChar){
>         super(cs, averageBytesPerChar, maxBytesPerChar);
>     }
>     public CoderResult decodeLoop(ByteBuffer out, CharBuffer in) {
>                 return CoderResult.UNDERFLOW;
>     }
> }

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


Mime
View raw message