-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.4.2
-
x86
-
windows_2000
Name: rmT116609Date: 03/22/2004
Bug 4913711 (which has been blocked from the Bug Database) is fixed in 1.4.2_05 and 5.0.
FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
A DESCRIPTION OF THE PROBLEM :
The One Japanese 2-byte code character(ex.\u3042)
is not converted for ISO2022JP encoding by String.getBytes,
it throw java.nio.BufferOverflowException.
"\u3042" ... throw Exception
"\u3043" ... throw Exception
...
"\u3042\u0061" .. Not throw Exception
"\u3042\u0061\u3042" ... throw Exception
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
with this code
byte[] bs = "\u3042".getBytes("ISO2022JP");
byte array bs is set as
(0x1b, 0x24, 0x42, 0x24, 0x22, 0x1b, 0x28, 0x42).
# ((byte)0x1b,...)
so, bs.length is not 5 but 8!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.nio.BufferOverflowException
at ava.nio.charset.CoderResult.throwExceptionCoderResult.java:259)
at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:343)
at java.lang.StringCoding.encode(StringCoding.java:374)
at java.lang.String.getBytes(String.java:573)
at Test.main(Test.java:4)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
// \u3042 means japanese 2byte hiragana "a"
byte[] b = "\u3042".getBytes("ISO2022JP");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
sun.nio.cs.ext.ISO2022_JP$Encoder.maxBytesPerChar is 5.0f,
so I patched this class file(set ConstantPool#5 as 8.0f)
<< 0000001e 04 40 a0 00 00
>> 0000001e 04 41 00 00 00
and execute java -Xbootclasspath/p
or
add dummy string(multiple "a" by target.length) and remove this string after String.getBytes().
(Incident Review ID: 244462)
======================================================================
###@###.### 10/21/04 20:59 GMT
Bug 4913711 (which has been blocked from the Bug Database) is fixed in 1.4.2_05 and 5.0.
FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
A DESCRIPTION OF THE PROBLEM :
The One Japanese 2-byte code character(ex.\u3042)
is not converted for ISO2022JP encoding by String.getBytes,
it throw java.nio.BufferOverflowException.
"\u3042" ... throw Exception
"\u3043" ... throw Exception
...
"\u3042\u0061" .. Not throw Exception
"\u3042\u0061\u3042" ... throw Exception
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
with this code
byte[] bs = "\u3042".getBytes("ISO2022JP");
byte array bs is set as
(0x1b, 0x24, 0x42, 0x24, 0x22, 0x1b, 0x28, 0x42).
# ((byte)0x1b,...)
so, bs.length is not 5 but 8!
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.nio.BufferOverflowException
at ava.nio.charset.CoderResult.throwExceptionCoderResult.java:259)
at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:343)
at java.lang.StringCoding.encode(StringCoding.java:374)
at java.lang.String.getBytes(String.java:573)
at Test.main(Test.java:4)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) throws Exception {
// \u3042 means japanese 2byte hiragana "a"
byte[] b = "\u3042".getBytes("ISO2022JP");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
sun.nio.cs.ext.ISO2022_JP$Encoder.maxBytesPerChar is 5.0f,
so I patched this class file(set ConstantPool#5 as 8.0f)
<< 0000001e 04 40 a0 00 00
>> 0000001e 04 41 00 00 00
and execute java -Xbootclasspath/p
or
add dummy string(multiple "a" by target.length) and remove this string after String.getBytes().
(Incident Review ID: 244462)
======================================================================
###@###.### 10/21/04 20:59 GMT