Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4997258

regression in CharEndcoder in 1.4.2_04

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2_04
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description


      @ Executing the following code in the BeanShell running on the JVM:
      @ .
      @ bsh% import java.nio.charset.Charset;
      @ bsh% final String CS_JIS0212 = "JIS0212";
      @ bsh% System.out.println(Charset.isSupported(CS_JIS0212) ? "Issupported"
      @ : "Not
      supported");
      @ bsh% Charset cs = Charset.forName(CS_JIS0212);
      @ bsh% System.out.println(cs.canEncode() ? "Can encode" : "Cannot encode");

      @ .
      @ Gives the following output:
      @ .
      @ bsh % Is supported
      @ bsh % Can encode
      @ .
      @ However,
      @ .
      @ bsh% String.valueOf('a').getBytes("JIS0212");
      @ .
      @ gives:
      @ .
      @ java.lang.IllegalArgumentException: Illegal replacement
      @ at
      @ java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
      @ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)

      @ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)

      @ at
      sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
      @ at sun.nio.cs.ext.JIS_X_0212$Encoder.<init>(JIS_X_0212.java:63)
      @ at sun.nio.cs.ext.JIS_X_0212.newEncoder(JIS_X_0212.java:34)
      @ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
      @ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
      @ at java.lang.StringCoding.encode(StringCoding.java:365)
      @ at java.lang.String.getBytes(String.java:573)
      @ .



      Or a simpler test case:

      @Using the JDK1.4.2_04 JVM running on Windows 2000 (SP4), executing the
      @ following line of code:
      @ .
      @ "a".getBytes("JIS0212");
      @ .
      @ results in the following exception:
      @ .
      @ java.lang.IllegalArgumentException: Illegal replacement
      @ at
      @ java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
      @ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)

      @ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)

      @ at
      sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
      @ at sun.nio.cs.ext.JIS_X_0212$Encoder.<init>(JIS_X_0212.java:63)
      @ at sun.nio.cs.ext.JIS_X_0212.newEncoder(JIS_X_0212.java:34)
      @ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
      @ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
      @ at java.lang.StringCoding.encode(StringCoding.java:365)
      @ at java.lang.String.getBytes(String.java:573)
      @ .
      @ Using JIS0208 also fails in a similar way.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hdongorcl Hao Dong (Inactive)
              Reporter:
              mmma Marvin Ma (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: