Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2016485 | 1.2.0 | Limin Shi | P1 | Resolved | Fixed | 1.2 |
Name: mgC56079 Date: 08/12/97
sun.io.ByteToCharKOI8_R.java contains wrong translation table.
The table should consist of 256 elements, not of 128.
Test:
=== Test.java ===
public class Test {
}
==== Compiler output ====
% javac -J-Dfile.encoding=KOI8_R Test.java
java.lang.ArrayIndexOutOfBoundsException: 240
at sun.io.ByteToCharSingleByte.convert(ByteToCharSingleByte.java:84)
at java.io.InputStreamReader.convertInto(InputStreamReader.java)
at java.io.InputStreamReader.fill(InputStreamReader.java)
at java.io.InputStreamReader.read(InputStreamReader.java)
at java.io.BufferedReader.fill(BufferedReader.java)
at java.io.BufferedReader.read(BufferedReader.java)
at sun.tools.java.ScannerInputStream.read(ScannerInputStream.java)
at sun.tools.java.Scanner.useInputStream(Scanner.java)
at sun.tools.java.Scanner.<init>(Scanner.java)
at sun.tools.java.Parser.<init>(Parser.java)
at sun.tools.javac.BatchParser.<init>(BatchParser.java)
at sun.tools.javac.BatchEnvironment.parseFile(BatchEnvironment.java)
at sun.tools.javac.Main.compile(Main.java)
at sun.tools.javac.Main.main(Main.java)
error: An exception has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
1 error
=========
======================================================================
[Another user - jso]
It still exists in JDK 1.1.4 I've just downloaded.
This is example code:
class t {
public static void main(String[] arg) throws Exception {
byte a[] = { (byte)'\u00c1', (byte)'\u00c2', (byte)'\u00c3', (byte)'\u00c4'
};
System.out.println(new String(a,"KOI8_R"));
byte b[] = { 'a', 'b', 'c', 'd' };
System.out.println(new String(b,"KOI8_R"));
}
}
It's result:
dima$ LANG=ru; export LANG; java t
ÐÑæÔ
java.lang.ArrayIndexOutOfBoundsException: 225
at sun.io.ByteToCharSingleByte.convert(ByteToCharSingleByte.java:84)
at java.lang.String.<init>(String.java)
at java.lang.String.<init>(String.java)
at java.lang.String.<init>(String.java)
at t.main(test.java:4)
Source of Error: entries for chars No 0-127 are missing in KOI8_R translation
table. Entries' indexes are 128-255.
Size of ByteToCharKOI8_R.class is about half of size of convertors of other
single byte charsets:
dima$ unzip /opt/jdk1.1.4/lib/classes.jar | fgrep ByteToChar
...
4277 08-30-97 13:37 sun/io/ByteToCharCp850.class
4277 08-30-97 13:37 sun/io/ByteToCharCp852.class
4277 08-30-97 13:37 sun/io/ByteToCharCp855.class
4279 08-30-97 13:37 sun/io/ByteToCharCp857.class
4277 08-30-97 13:37 sun/io/ByteToCharCp860.class
4277 08-30-97 13:37 sun/io/ByteToCharCp861.class
...
4250 08-30-97 13:43 sun/io/ByteToCharMS874.class
2366 08-30-97 13:43 sun/io/ByteToCharKOI8_R.class
--////
Correct code for ByteToCharKOI8_R.java:
(Old part (indexes 0-127) were obtained by disassembling of
ByteToCharKOI8_R.class. New part (indexes 128-255) are marked with
"/**/" sequence. After commenting out new part compiler /*should*/
produce original .class file )
begin 664 ByteToCharKOI8_R.java.gz
M'XL("-#N@C, T)Y=&54;T-H87)+3TDX7U(N:F%V80!=5<%NU# 0/3=?8?4$
M%6QCQQX[JKB ." .2+0WA%"Z#4OHDEUELQ6HZK^3>6_45JW4/,4S[]F>>;/9
M=^O;;M.[PW%<#;N+:OBSWTVS^]W==:MM-VY69X]K3%F]_S?W5[L/O[KI<A@W
MVU[?+ZK]\7H[K-UZVQT.[BGE\Y=/Y<=7U_^=^_'F>>")6]U7;ODS@<MY6B)N
MT\^:U:WG?OHXKG<WR^*KU^Z^.IGZ^3B-[O1V-Y2WT^D%R ^$_33<=7/O?@YC
MMW7K1<!=/^YXU5UO^V_?W3M5:6,.;P 14 P*H&6L%854UP3$DN=B "$UR!2F
M2!T)R!3/& GB,\%B[0*EY48"E9(#%G-3 [+R2H'F FD!+S5IC;X@P6<5]$57
M0L0>*05"0U ![R&PO!GP%LD(O%IJ <+[BB=03"@FO+901:@B5!&JB*KX.C E
M4RQ3C$5/F6*L?<J62;%,L4RQS".5&K=O>9. #;(!:E&WD6]"R%RTE,0W9E*K
M+I[ E&(QJA02"L5*YK:64@B\94NQEF+L19VMXA9C9C:",$9":^>T QJ=O&C
M3.$Y(P\821!+X<F$F9$JD?LEIB3&$E42"71&G2B6+8673CQ9HEBB6&0L4D48
M$V9&@E#33"!V3CO@0C\_.SNO3G H=>SRKS$E::KJJPZ:#PZJI0_L"1WLP''
M ,#_^E!&4$: MC("YT(?R@C*",H(RL# 8=P:96 ,&V4TRFB4T2BC44:CC$89
MZ SZ@DJ@_&@,VH(BH1KH!/J +J 'Z #JC^JC]B@Y"HYRH]AH+3J*SJ."J"U*
MBL%#X=$$5!NV01,Q&9@+.!'VQV!@+&!2N!&3@#G %& &, 'P/]P/[\/R,#SL
M#K/SEPMSS"G6!R88\XL&LH,T(,U%X] -9CXZ@P[$DZZR4<<37!J #J %Z &:
M@"Z@#> ##R/X0.^ "R]XF,'##1YV\.H'V/+9EV3Y1!R.^WY:O?A^+%^/%ROV
. :H>JNH_O,6'^4P' !X
end
HTH. I like java.
Dmitry
- backported by
-
JDK-2016485 sun.io.ByteToCharKOI8_R.java converter is broken
- Resolved
- duplicates
-
JDK-4064093 KOI8 to UNICODE convertor rises index out of bounds exeption on ASCII symbols
- Closed
-
JDK-4091025 exception thrown from InputStreamReader - koi8-r charset
- Closed