United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6954992 how to handle tilde char. in jdk6 should be backport to jdk5
JDK-6954992 : how to handle tilde char. in jdk6 should be backport to jdk5

Details
Type:
Bug
Submit Date:
2010-05-24
Status:
Closed
Updated Date:
2012-06-08
Project Name:
JDK
Resolved Date:
2010-07-13
Component:
xml
OS:
windows_vista
Sub-Component:
jaxp
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0u21
Fixed Versions:
5.0u25-rev (b04)

Related Reports
Backport:
Backport:

Sub Tasks

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
EVALUATION

Need to backport this fix from 6.
                                     
2010-05-25
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};
                                     
2010-06-15



Hardware and Software, Engineered to Work Together