[kaffe] CVS kaffe (robilad): Fixed serialization again
Kaffe CVS
cvs-commits at kaffe.org
Wed Sep 29 10:34:41 PDT 2004
PatchSet 5234
Date: 2004/09/29 16:44:06
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Fixed serialization again
2004-09-29 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/lang/String.java:
(String) Replaced constructors decoding bytes with
implementations from GNU Classpath.
(decodeBytes) Simplified.
* libraries/javalib/kaffe/io/ConverterAlias.java:
Use iconv for all encodings if iconv is available.
Reported by: Ito Kazumitsu <kaz at maczuka.gcd.org>
Members:
ChangeLog:1.2788->1.2789
libraries/javalib/java/lang/String.java:1.41->1.42
libraries/javalib/kaffe/io/ConverterAlias.java:1.18->1.19
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2788 kaffe/ChangeLog:1.2789
--- kaffe/ChangeLog:1.2788 Wed Sep 29 05:08:19 2004
+++ kaffe/ChangeLog Wed Sep 29 16:44:06 2004
@@ -1,3 +1,15 @@
+2004-09-29 Dalibor Topic <robilad at kaffe.org>
+
+ * libraries/javalib/java/lang/String.java:
+ (String) Replaced constructors decoding bytes with
+ implementations from GNU Classpath.
+ (decodeBytes) Simplified.
+
+ * libraries/javalib/kaffe/io/ConverterAlias.java:
+ Use iconv for all encodings if iconv is available.
+
+ Reported by: Ito Kazumitsu <kaz at maczuka.gcd.org>
+
2004-09-28 Timothy S. Stack <stack at cs.utah.edu>
* developers/mnemonicizer.awk:
Index: kaffe/libraries/javalib/java/lang/String.java
diff -u kaffe/libraries/javalib/java/lang/String.java:1.41 kaffe/libraries/javalib/java/lang/String.java:1.42
--- kaffe/libraries/javalib/java/lang/String.java:1.41 Mon Mar 22 11:24:47 2004
+++ kaffe/libraries/javalib/java/lang/String.java Wed Sep 29 16:44:09 2004
@@ -10,14 +10,17 @@
package java.lang;
+import gnu.java.io.decode.Decoder;
+import gnu.java.io.EncodingManager;
+
import java.io.ByteArrayOutputStream;
+import java.io.CharConversionException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Comparator;
import java.util.Locale;
import java.util.regex.Pattern;
-import kaffe.io.ByteToCharConverter;
import kaffe.io.CharToByteConverter;
public final class String implements Serializable, Comparable, CharSequence {
@@ -81,14 +84,15 @@
}
public String(byte[] bytes) {
- this(decodeBytes(bytes, 0,
- bytes.length, ByteToCharConverter.getDefault()));
+ this(bytes, 0, bytes.length);
}
-public String(byte[] bytes, String enc) throws UnsupportedEncodingException {
- this(decodeBytes(bytes, 0,
- bytes.length, ByteToCharConverter.getConverter(enc)));
-}
+/* taken from GNU Classpath */
+ public String(byte[] data, String encoding)
+ throws UnsupportedEncodingException
+ {
+ this(data, 0, data.length, encoding);
+ }
/**
* @deprecated
@@ -97,16 +101,52 @@
this(ascii, hibyte, 0, ascii.length);
}
-public String(byte[] bytes, int offset, int length) {
- this(decodeBytes(bytes, offset,
- length, ByteToCharConverter.getDefault()));
-}
-
-public String(byte[] bytes, int offset, int length, String enc)
- throws UnsupportedEncodingException {
- this(decodeBytes(bytes, offset,
- length, ByteToCharConverter.getConverter(enc)));
-}
+/* taken from GNU Claspath */
+ public String(byte[] data, int offset, int count)
+ {
+ if (offset < 0 || count < 0 || offset + count > data.length)
+ throw new StringIndexOutOfBoundsException();
+ try
+ {
+ // XXX Consider using java.nio here.
+ value = EncodingManager.getDecoder()
+ .convertToChars(data, offset, count);
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new Error(uee);
+ }
+ catch (CharConversionException cce)
+ {
+ throw new Error(cce);
+ }
+ this.offset = 0;
+ this.count = value.length;
+ }
+
+/* taken from GNU Claspath */
+ public String(byte[] data, int offset, int count, String encoding)
+ throws UnsupportedEncodingException
+ {
+ if (offset < 0 || count < 0 || offset + count > data.length)
+ throw new StringIndexOutOfBoundsException();
+ try
+ {
+ // XXX Consider using java.nio here.
+ value = EncodingManager.getDecoder(encoding)
+ .convertToChars(data, offset, count);
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new Error(uee);
+ }
+ catch (CharConversionException cce)
+ {
+ throw new Error(cce);
+ }
+ this.offset = 0;
+ this.count = value.length;
+ }
/**
* @deprecated
@@ -334,16 +374,9 @@
return -1;
}
-private static StringBuffer decodeBytes(byte[] bytes, int offset,
- int len, ByteToCharConverter encoding) {
- StringBuffer sbuf = new StringBuffer(len);
- char[] out = new char[512];
- int outlen = encoding.convert(bytes, offset, len, out, 0, out.length);
- while (outlen > 0) {
- sbuf.append(out, 0, outlen);
- outlen = encoding.flush(out, 0, out.length);
- }
- return sbuf;
+private static char[] decodeBytes(byte[] bytes, int offset,
+ int len, Decoder decoder) throws CharConversionException {
+ return decoder.convertToChars(bytes, offset, len);
}
public int lastIndexOf( String str) {
Index: kaffe/libraries/javalib/kaffe/io/ConverterAlias.java
diff -u kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.18 kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.19
--- kaffe/libraries/javalib/kaffe/io/ConverterAlias.java:1.18 Tue Jan 6 16:27:54 2004
+++ kaffe/libraries/javalib/kaffe/io/ConverterAlias.java Wed Sep 29 16:44:10 2004
@@ -38,6 +38,7 @@
alias.put("IBM819", "8859_1");
alias.put("CP819", "8859_1");
alias.put("CSISOLATIN1", "8859_1");
+ useIconv.put("8859_1", "Y");
alias.put("ISO_8859-2:1987", "8859_2");
alias.put("ISO-IR-101", "8859_2");
@@ -46,6 +47,7 @@
alias.put("LATIN2", "8859_2");
alias.put("L2", "8859_2");
alias.put("CSISOLATIN2", "8859_2");
+ useIconv.put("8859_2", "Y");
alias.put("ISO_8859-3:1988", "8859_3");
alias.put("ISO-IR-109", "8859_3");
@@ -54,6 +56,7 @@
alias.put("LATIN3", "8859_3");
alias.put("L3", "8859_3");
alias.put("CSISOLATIN3", "8859_3");
+ useIconv.put("8859_3", "Y");
alias.put("ISO_8859-4:1988", "8859_4");
alias.put("ISO-IR-110", "8859_4");
@@ -62,6 +65,7 @@
alias.put("LATIN4", "8859_4");
alias.put("L4", "8859_4");
alias.put("CSISOLATIN4", "8859_4");
+ useIconv.put("8859_4", "Y");
alias.put("ISO_8859-5:1988", "8859_5");
alias.put("ISO-IR-144", "8859_5");
@@ -69,6 +73,7 @@
alias.put("ISO-8859-5", "8859_5");
alias.put("CYRILLIC", "8859_5");
alias.put("CSISOLATINCYRILLIC", "8859_5");
+ useIconv.put("8859_5", "Y");
alias.put("ISO_8859-6:1987", "8859_6");
alias.put("ISO-IR-127", "8859_6");
@@ -78,6 +83,7 @@
alias.put("ASMO-708", "8859_6");
alias.put("ARABIC", "8859_6");
alias.put("CSISOLATINARABIC", "8859_6");
+ useIconv.put("8859_6", "Y");
alias.put("ISO_8859-7:1987", "8859_7");
alias.put("ISO-IR-126", "8859_7");
@@ -88,6 +94,7 @@
alias.put("GREEK", "8859_7");
alias.put("GREEK8", "8859_7");
alias.put("CSISOLATINGREEK", "8859_7");
+ useIconv.put("8859_7", "Y");
alias.put("ISO_8859-8:1988", "8859_8");
alias.put("ISO-IR-138", "8859_8");
@@ -95,6 +102,7 @@
alias.put("ISO-8859-8", "8859_8");
alias.put("HEBREW", "8859_8");
alias.put("CSISOLATINHEBREW", "8859_8");
+ useIconv.put("8859_8", "Y");
alias.put("ISO_8859-9:1989", "8859_9");
alias.put("ISO-IR-148", "8859_9");
@@ -103,13 +111,17 @@
alias.put("LATIN5", "8859_9");
alias.put("L5", "8859_9");
alias.put("CSISOLATIN5", "8859_9");
+ useIconv.put("8859_9", "Y");
alias.put("EBCDIC", "CP1046");
+ useIconv.put("CP1046", "Y");
alias.put("UTF-8", "UTF8");
+ useIconv.put("UTF8", "Y");
alias.put("KOI8-R", "KOI8_R");
alias.put("CSKOI8R", "KOI8_R");
+ useIconv.put("KOI8_R", "Y");
alias.put("EUCJP", "EUC-JP");
alias.put("EUC_JP", "EUC-JP");
@@ -127,6 +139,7 @@
alias.put("IBM367", "ASCII");
alias.put("CP367", "ASCII");
alias.put("CPASCII", "ASCII");
+ useIconv.put("ASCII", "Y");
alias.put("UNICODEBIGUNMARKED", "UTF-16BE");
useIconv.put("UTF-16BE", "Y");
More information about the kaffe
mailing list