I submitted the patch written by Rafael Teixeira:
http://developer.classpath.org/pipermail/classpath-patches/2006-February/000473.html
that fixes BigInteger serialization.
2006-02-28 Anthony Balkissoon <[EMAIL PROTECTED]>
* java/math/BigInteger.java:
Committed patch by Rafael:
developer.classpath.org/pipermail/classpath-patches/
2006-February/000473.html
(signum): Return early 0 if words == null and ival == 0.
(readObject): Handle special case of magnitude.length or signum being
0.
(writeObject): If signum is zero return a zero-sized byte[].
--Tony
? patch.diff
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: java/math/BigInteger.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.26
diff -u -r1.26 BigInteger.java
--- java/math/BigInteger.java 21 Sep 2005 17:00:33 -0000 1.26
+++ java/math/BigInteger.java 28 Feb 2006 17:59:13 -0000
@@ -356,9 +356,9 @@
public int signum()
{
- int top = words == null ? ival : words[ival-1];
- if (top == 0 && words == null)
+ if (ival == 0 && words == null)
return 0;
+ int top = words == null ? ival : words[ival-1];
return top < 0 ? -1 : 1;
}
@@ -2227,17 +2227,25 @@
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
- words = byteArrayToIntArray(magnitude, signum < 0 ? -1 : 0);
- BigInteger result = make(words, words.length);
- this.ival = result.ival;
- this.words = result.words;
+ if (magnitude.length == 0 || signum == 0)
+ {
+ this.ival = 0;
+ this.words = null;
+ }
+ else
+ {
+ words = byteArrayToIntArray(magnitude, signum < 0 ? -1 : 0);
+ BigInteger result = make(words, words.length);
+ this.ival = result.ival;
+ this.words = result.words;
+ }
}
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException
{
signum = signum();
- magnitude = toByteArray();
+ magnitude = signum == 0 ? new byte[0] : toByteArray();
s.defaultWriteObject();
}
}