[Bug libgcj/29178] New: CharsetEncoder.canEncode() gives different results than Sun version

marcus at better dot se gcc-bugzilla@gcc.gnu.org
Fri Sep 22 08:21:00 GMT 2006

The following test program gives different results with gcj and Sun JDK:

// A.java
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;

public class A {
    public static void main(String[] args) throws java.io.IOException
        CharsetEncoder enc = Charset.forName("US-ASCII").newEncoder();
// end

$ javac A.java
$ /usr/lib/jvm/java-1.5.0-sun/bin/java A
$ /usr/lib/jvm/java-gcj/bin/java A

The Sun version seems to return something like (c > 31 && c < 127),
which makes sense, whereas gcj apparently always returns true.

This breaks lots of code, such as Apache JaxMe 2 version 0.51
(specifically the MarshallerTest in the test suite, which generated
invalid XML with gcj).

This was tested on Debian (testing, i386).

~$ gcj --version
gcj (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)

The bug was also reported to Debian's bug tracking system:

           Summary: CharsetEncoder.canEncode() gives different results than
                    Sun version
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marcus at better dot se
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


More information about the Java-prs mailing list