Bug 21140 - [4.0 only] Charset.encode and Charset.decode broken
Summary: [4.0 only] Charset.encode and Charset.decode broken
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-21 03:54 UTC by Luca Barbieri
Modified: 2005-05-17 01:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0
Known to fail: 4.0.0
Last reconfirmed: 2005-04-21 05:28:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Barbieri 2005-04-21 03:54:04 UTC
Charset.encode and Charset.decode only work for a single call.

The reason is that the encoder/decoder is cached and after the first call it
will be in the flushed state.

The second call will thus throw an InvalidStateException.

Removing the cache or resetting the cached object should solve this.
Comment 1 Michael Koch 2005-04-21 05:28:02 UTC
This bug is fixed in GNU classpath and I will merge the needed fixes soon. 
Comment 2 Andrew Pinski 2005-04-28 02:23:46 UTC
Fixed on the mainline by:
2005-04-27  Sven de Marothy  <sven@physto.se>

        * java/nio/charset/Charset.java: Cached encoders shouldn't be static.
        
2005-04-27  Sven de Marothy  <sven@physto.se> 

        * java/nio/charset/Charset.java: Reset cached de/encoders.

Hmm, I think these patches should be backported to 4.0.1.
Comment 3 Andrew Haley 2005-04-28 11:00:12 UTC
Added to Tom Tromey's queue for 4.0 branch.
Comment 4 Tom Tromey 2005-05-04 21:45:00 UTC
Note that the patch from the trunk can't be applied to the 4.0
branch, as it would break compatibility for the C++ ABI.
My current leaning is to simply disable the caching in 4.0.1.
Comment 5 GCC Commits 2005-05-17 01:46:10 UTC
Subject: Bug 21140

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tromey@gcc.gnu.org	2005-05-17 01:46:06

Modified files:
	libjava        : ChangeLog 
	libjava/java/nio/charset: Charset.java 

Log message:
	PR libgcj/21140:
	* java/nio/charset/Charset.java (encode, decode): Don't cache.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.69&r2=1.3391.2.70
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/nio/charset/Charset.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.9&r2=1.9.2.1

Comment 6 Tom Tromey 2005-05-17 01:50:24 UTC
Fix checked in.