JDK-6954992 : how to handle tilde char. in jdk6 should be backport to jdk5
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 5.0u21
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2010-05-24
  • Updated: 2012-06-08
  • Resolved: 2010-07-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other
5.0u25-rev b04Fixed 5.0u26-revFixed 5.0u27Fixed
Description
Our CU's customer faces with the difference behavior between jdk6 and jdk5,
when their program tries to output a XML object including tilde(multibyte, \uFF5E) char.
to xml file in Shift-JIS.

REPRODUCE:
1. Compile the attached d.java
2. Invoke "java -showversion d"
3. Invoke "type a.xml"

The results are as followis.

C:\Users\licensees\tilde>java -showversion d
java version "1.5.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20-b02)
Java HotSpot(TM) Client VM (build 1.5.0_20-b02, mixed mode)


C:\Users\licensees\tilde>type a.xml
<?xml version="1.0" encoding="Shift_JIS"?><root><data>?</data></root>
C:\Users\tbaba\licensees\childer>set path=C:\Users\tbaba\java\jdk6_18\bin;%path%


C:\Users\licensees\tilde>java -showversion d
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode)


C:\Users\licensees\tilde>type a.xml
<?xml version="1.0" encoding="Shift_JIS" standalone="no"?><root><data>&#65374;</
data></root>

The above result  says,

JDK5 : tilde is output as "?"
JDK6 : tilde is outpu &#65374 (escaped)

The way of handling tilde in jdk6 should be backport to jdk5.

INVESTIGATION:
SUN_CHAR2BYTE_CONVERTER_METHOD to which getCharToByteConverter(String encoding)  in Encodings.java refers is always null in jdk5. This seems to cause thsi problem in jdk5.

NOTE:
Suggested fix is provided for jdk5u24. Please see attached "Encodings.java".

Comments
SUGGESTED FIX src/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java *** 66,76 **** SUN_CHAR2BYTE_CONVERTER_METHOD = findCharToByteConverterMethod(); private static Method findCharToByteConverterMethod() { try { ! AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { Class charToByteConverterClass = (Class) Class.forName("sun.io.CharToByteConverter"); Class argTypes[] = {String.class}; --- 66,76 ---- SUN_CHAR2BYTE_CONVERTER_METHOD = findCharToByteConverterMethod(); private static Method findCharToByteConverterMethod() { try { ! return (Method)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { Class charToByteConverterClass = (Class) Class.forName("sun.io.CharToByteConverter"); Class argTypes[] = {String.class};
15-06-2010

EVALUATION Need to backport this fix from 6.
25-05-2010