[cp-patches] java.nio.charset.CharsetEncoder fixlet

Tom Tromey tromey at redhat.com
Mon Mar 5 18:58:11 UTC 2007


>>>>> "Marco" == Marco Trudel <mtrudel at gmx.ch> writes:

Marco> The attached CharsetEncoderTest.java fails on Windows with an
Marco> IllegalStateException. It works on Linux. I don't know why, but I
Marco> assume because it doesn't need a CharsetEncoder.

Yeah, I think the Linux code may take a different path on this
particular test case.  But, I do see a similar bug here on Linux with
Mauve.

Marco> The problem is that this sequence will be called:
Marco> 1. encode (CharBuffer in, ByteBuffer out,    boolean endOfInput = true)
Marco> -> state will be "STATE_END"
Marco> 2. flush (ByteBuffer out)
Marco> -> state will be "STATE_FLUSHED" what is basically the same as "STATE_END"
Marco> 3. encode (CharBuffer in, ByteBuffer out,    boolean endOfInput = true)

According to the JDK javadoc, this sequence is invalid.  The last call
to encode must come before flush.

So, I think we have to fix the caller instead.

Tom



More information about the Classpath-patches mailing list