JDK-4997258 : regression in CharEndcoder in 1.4.2_04
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.4.2_04
  • Priority: P1
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2004-02-19
  • Updated: 2004-03-02
  • Resolved: 2004-03-02
Related Reports
Duplicate :  
Relates :  
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.  

Comments
EVALUATION This bug exists only in 1.4.2_04 (not in 1.4.2, 1.4.2_03, or 1.5-beta2-b39). It is likely caused by the fix for bug 4904370. -- iag@sfbay 2004-02-19 Fix for 4904370 is not complete. Additional code which is already in 1.5.0 and which specifically addressed bugID 4766311 needs to be backported to augment the incomplete fix provided for 4904370. ###@###.### 2004-02-20
20-02-2004