Paulex,

look at the class description in the spec:

"A decoder should always be used by making the following sequence of
method invocations, hereinafter referred to as a decoding operation:

Reset the decoder via the reset method, unless it has not been used before;

Invoke the decode method zero or more times, as long as additional
input may be available, passing false for the endOfInput argument and
filling the input buffer and flushing the output buffer between
invocations;

Invoke the decode method one final time, passing true for the
endOfInput argument; and then

Invoke the flush method so that the decoder can flush any internal
state to the output buffer. "

So RI works according to class description. It might be a misprint in the
method description you have cited. I'd rather be compatible with RI

Thanks,
Mikhail


On 2/22/06, Paulex Yang <[EMAIL PROTECTED]> wrote:
> Following the discussion before, I have another issue about RI's "bug",
>
> try this little test below:
>
> import java.nio.charset.*;
> public class DecoderTest{
>    public static void main(String[] args){
>            CharsetDecoder decoder = Charset.forName("utf-8").newDecoder();
>        decoder.reset();
>        decoder.flush(CharBuffer.allocate(10));
>    }
> }
>
> It quits quietly on Harmony, while on RI(JDK 5.0/1.4.2), it throws
> exception like below:
> java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED
>    at
> java.nio.charset.CharsetDecoder.throwIllegalStateException(Unknown Source)
>    at java.nio.charset.CharsetDecoder.flush(Unknown Source)
>    ........
>
> But the spec of CharsetDecoder.flush() says:
>
> Throws:
>    IllegalStateException - If the previous step of the current decoding
> operation was an invocation neither of the reset method nor of the
> three-argument decode method with a value of true for the endOfInput
> parameter
>
> It's so interesting that the spec emphasizes it SHOULD NOT throw
> IllegalStateException when flush() just after reset().
>
> In fact, this is just one example of contradiction between spec and RI's
> CharsetDecoder/Encoder internal status implementation. These *bugs*  are
> serious so that the RI's Decoder/Encoder must be used by experiment.
> Should Harmony be compatible with RI?
>
>
>
> --
> Paulex Yang
> China Software Development Lab
> IBM
>
>
>

Reply via email to