harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Hindess" <mark.hind...@googlemail.com>
Subject Re: [jira] Updated: (HARMONY-150) java.nio.charset.Charset.decode(in) doesn't use the same cached decoder.
Date Tue, 14 Mar 2006 06:44:59 GMT
Should the Anonymous user really be permitted to submit attachments? 
We can't really use them unless provenance is clear.

I assume this was submitted by Richard but

-Mark.

On 3/14/06, Anonymous (JIRA) <jira@apache.org> wrote:
>      [ http://issues.apache.org/jira/browse/HARMONY-150?page=all ]
>
>  updated HARMONY-150:
> ---------------------
>
>     Attachment: CharsetTest_Patch_150.txt
>
> > java.nio.charset.Charset.decode(in) doesn't use the same cached decoder.
> > ------------------------------------------------------------------------
> >
> >          Key: HARMONY-150
> >          URL: http://issues.apache.org/jira/browse/HARMONY-150
> >      Project: Harmony
> >         Type: Bug
> >   Components: Classlib
> >     Reporter: Richard Liang
> >  Attachments: CharsetTest_Patch_150.txt, Charset_patch_150.txt
> >
> > java.nio.charset.Charset.decode(in) doesn't use the same cached decoder.
> > As spec says, "An invocation of this method upon a charset cs returns the same result
as the expression  cs.newDecoder() .onMalformedInput(CodingErrorAction.REPLACE) .onUnmappableCharacter(CodingErrorAction.REPLACE)
 .decode(bb); except that it is potentially more efficient because it can cache decoders between
successive invocations. "
> > RI always uses the same cached decoder (the same reference) for the same name charset.
For details, please refer to the test case below:
> > ======== test case output =====
> > RI 5.0 passes the test case while Harmony fails.
> > ======== test case===========
> > /*
> >        * test cached decoder
> >        */
> >       public void testCachedDecoder() throws Exception{
> >               MockCachedCharset cs1 = new MockCachedCharset("CachedCharset",null);
> >               MockCachedCharset cs2 = new MockCachedCharset("CachedCharset",null);
> >               ByteBuffer in = ByteBuffer.wrap(new byte[]{0x00});
> >               cs1.decode(in);
> >               in.flip();
> >               cs2.decode(in);
> >               in.flip();
> >       }
> >       /*
> >        * Mock Charset for cached decoder test
> >        */
> >       static class MockCachedCharset extends Charset{
> >               public MockCachedCharset(String canonicalName, String[] aliases){
> >                       super(canonicalName, aliases);
> >               }
> >               public boolean contains(Charset charset) {
> >                       return false;
> >               }
> >               public CharsetEncoder newEncoder() {
> >                       return null;
> >               }
> >               public CharsetDecoder newDecoder() {
> >                       return new MockCachedDecoder(this);
> >               }
> >
> >
> >       }
> >       /*
> >        * Mock decoder. Only one caller is permitted.
> >        */
> >       static class MockCachedDecoder extends CharsetDecoder {
> >               static MockCachedDecoder caller = null;
> >
> >               public MockCachedDecoder(Charset cs) {
> >                       super(cs, 1, 10);
> >               }
> >               /*
> >                * Only one caller is permitted.
> >                * If there's another caller, throw RuntimeException.
> >                */
> >               protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
> >                       if(null == caller){
> >                               caller = this;
> >                       }else{
> >                               if(caller != this){
> >                                       // Another instance
> >                                       throw new RuntimeException();
> >                               }
> >                       }
> >                       return CoderResult.UNDERFLOW;
> >               }
> >       }
>
> --
> 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
>
>


--
Mark Hindess <mark.hindess@googlemail.com>
IBM Java Technology Centre, UK.

Mime
View raw message