Commit df98a50b by Warren Levy Committed by Warren Levy

Makefile.am: Added locale files from Classpath.

	* Makefile.am: Added locale files from Classpath.
	* Makefile.in: Rebuilt.
	* gnu/java/locale/Calendar.java: New file.
	* gnu/java/locale/Calendar_de.java: New file.
	* gnu/java/locale/Calendar_en.java: New file.
	* gnu/java/locale/Calendar_nl.java: New file.
	* java/lang/ClassNotFoundException.java: Replaced with Classpath file.
	* java/math/BigDecimal.java (intVal): Renamed from 'num' for
	serialization compatibility.
	(scale): Made private.
	(serialVersionUID): New field.
	* java/math/BigInteger.java (ival): Made transient.
	(words): Made transient.
	(bitCount): New serialization field.
	(bitLength): Ditto.
	(firstNonzeroByteNum): Ditto.
	(lowestSetBit): Ditto.
	(magnitude): Ditto.
	(signum): Ditto.
	(serialVersionUID): New field.
	(readObject): New method.
	(writeObject): New method.
	* java/util/BitSet.java (serialVersionUID): New field.
	* java/util/Calendar.java: Replaced with Classpath file.
	* java/util/GregorianCalendar.java (GregorianCalendar): Pass result
	of getDefault() for TimeZone or Locale instead of passing nulls.
	* java/util/Locale.java (serialVersionUID): New field.
	(writeObject): New method.
	(readObject): New method.
	* java/util/SimpleTimeZone.java: Replaced with Classpath file.

Serialization mods.

From-SVN: r37080
parent c11a0324
2000-10-27 Warren Levy <warrenl@cygnus.com>
* Makefile.am: Added locale files from Classpath.
* Makefile.in: Rebuilt.
* gnu/java/locale/Calendar.java: New file.
* gnu/java/locale/Calendar_de.java: New file.
* gnu/java/locale/Calendar_en.java: New file.
* gnu/java/locale/Calendar_nl.java: New file.
* java/lang/ClassNotFoundException.java: Replaced with Classpath file.
* java/math/BigDecimal.java (intVal): Renamed from 'num' for
serialization compatibility.
(scale): Made private.
(serialVersionUID): New field.
* java/math/BigInteger.java (ival): Made transient.
(words): Made transient.
(bitCount): New serialization field.
(bitLength): Ditto.
(firstNonzeroByteNum): Ditto.
(lowestSetBit): Ditto.
(magnitude): Ditto.
(signum): Ditto.
(serialVersionUID): New field.
(readObject): New method.
(writeObject): New method.
* java/util/BitSet.java (serialVersionUID): New field.
* java/util/Calendar.java: Replaced with Classpath file.
* java/util/GregorianCalendar.java (GregorianCalendar): Pass result
of getDefault() for TimeZone or Locale instead of passing nulls.
* java/util/Locale.java (serialVersionUID): New field.
(writeObject): New method.
(readObject): New method.
* java/util/SimpleTimeZone.java: Replaced with Classpath file.
2000-10-25 Bryce McKinlay <bryce@albatross.co.nz> 2000-10-25 Bryce McKinlay <bryce@albatross.co.nz>
* Makefile.am (GCJCOMPILE): Pass --tag=GCJ to libtool. * Makefile.am (GCJCOMPILE): Pass --tag=GCJ to libtool.
......
...@@ -998,6 +998,10 @@ gnu/java/io/ObjectIdentityWrapper.java \ ...@@ -998,6 +998,10 @@ gnu/java/io/ObjectIdentityWrapper.java \
gnu/java/lang/ArrayHelper.java \ gnu/java/lang/ArrayHelper.java \
gnu/java/lang/ClassHelper.java \ gnu/java/lang/ClassHelper.java \
gnu/java/lang/reflect/TypeSignature.java \ gnu/java/lang/reflect/TypeSignature.java \
gnu/java/locale/Calendar.java \
gnu/java/locale/Calendar_de.java \
gnu/java/locale/Calendar_en.java \
gnu/java/locale/Calendar_nl.java \
gnu/java/security/provider/Gnu.java \ gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \ gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \ gnu/java/security/provider/SHA1PRNG.java \
......
...@@ -742,6 +742,10 @@ gnu/java/io/ObjectIdentityWrapper.java \ ...@@ -742,6 +742,10 @@ gnu/java/io/ObjectIdentityWrapper.java \
gnu/java/lang/ArrayHelper.java \ gnu/java/lang/ArrayHelper.java \
gnu/java/lang/ClassHelper.java \ gnu/java/lang/ClassHelper.java \
gnu/java/lang/reflect/TypeSignature.java \ gnu/java/lang/reflect/TypeSignature.java \
gnu/java/locale/Calendar.java \
gnu/java/locale/Calendar_de.java \
gnu/java/locale/Calendar_en.java \
gnu/java/locale/Calendar_nl.java \
gnu/java/security/provider/Gnu.java \ gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \ gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \ gnu/java/security/provider/SHA1PRNG.java \
...@@ -1256,6 +1260,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ ...@@ -1256,6 +1260,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/io/ObjectIdentityWrapper.P \ .deps/gnu/java/io/ObjectIdentityWrapper.P \
.deps/gnu/java/lang/ArrayHelper.P .deps/gnu/java/lang/ClassHelper.P \ .deps/gnu/java/lang/ArrayHelper.P .deps/gnu/java/lang/ClassHelper.P \
.deps/gnu/java/lang/reflect/TypeSignature.P \ .deps/gnu/java/lang/reflect/TypeSignature.P \
.deps/gnu/java/locale/Calendar.P .deps/gnu/java/locale/Calendar_de.P \
.deps/gnu/java/locale/Calendar_en.P .deps/gnu/java/locale/Calendar_nl.P \
.deps/gnu/java/security/provider/Gnu.P \ .deps/gnu/java/security/provider/Gnu.P \
.deps/gnu/java/security/provider/SHA.P \ .deps/gnu/java/security/provider/SHA.P \
.deps/gnu/java/security/provider/SHA1PRNG.P .deps/interpret.P \ .deps/gnu/java/security/provider/SHA1PRNG.P .deps/interpret.P \
......
/* Calendar.java -- Default Calendar locale data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package gnu.java.locale;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.Date;
/**
* This class contains locale data for java.util.Calendar.<br>
*
* If you localize this to another language only set fields, that
* you change. See Calendar_de for an example. Also add your
* locale to this list of availableLocales below in this(!) file.
*
* @author Jochen Hoenicke
*/
public class Calendar extends ListResourceBundle
{
/**
* The locales for which Calendar is localized.
*/
private static final Locale[] availableLocales = {
Locale.GERMAN, Locale.ENGLISH, new Locale("nl", "")
};
/**
* This is the default calendar class, that is returned on
* java.util.Calendar.getInstance().
* @see java.util.Calendar#getInstance()
*/
private static final String calendarClass = "java.util.GregorianCalendar";
/**
* This is used by java.util.Calendar.
* @see java.util.Calendar#getFirstDayOfWeek()
*/
private static final Integer firstDayOfWeek
= new Integer(java.util.Calendar.SUNDAY);
/**
* This is used by java.util.Calendar.
* @see java.util.Calendar#getMinimalDaysInFirstWeek()
*/
private static final Integer minimalDaysInFirstWeek = new Integer(1);
/**
* The point at which the Gregorian calendar rules were used.
* The default for most catholic
* countries is midnight (UTC) on October 5, 1582 (Julian),
* or October 15, 1582 (Gregorian).
* @see java.util.GregorianCalendar#getGregorianCutOver
*/
/* If you change this date be aware, that this formular does only
* work for months from MARCH to DECEMBER and doesn't work in
* leap years (look in java.util.GregorianCalendar.getDayOfYear for
* more info).
*/
private static final Date gregorianCutOver = new Date
((24*60*60*1000L) *
(((1582*(365*4+1))/4 +
(java.util.Calendar.OCTOBER*(31+30+31+30+31) - 9) / 5 + 5) -
((1970*(365*4+1))/4 + 1 - 13)));
/**
* This is the object array used to hold the keys and values
* for this bundle
*/
private static final Object[][] contents =
{
{ "availableLocales", availableLocales },
{ "calendarClass", calendarClass },
{ "firstDayOfWeek", firstDayOfWeek },
{ "minimalDaysInFirstWeek", minimalDaysInFirstWeek },
{ "gregorianCutOver", gregorianCutOver }
};
/**
* This method returns the object array of key, value pairs containing
* the data for this bundle.
*
* @return The key, value information.
*/
public Object[][] getContents()
{
return(contents);
}
}
/* Calendar_de.java -- German calendar locale data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package gnu.java.locale;
import java.util.ListResourceBundle;
import java.util.Calendar;
/**
* This class contains locale data for java.util.Calendar specific for
* german language.
* @author Jochen Hoenicke
*/
public class Calendar_de extends ListResourceBundle
{
/**
* This is the object array used to hold the keys and values
* for this bundle
*/
private static final Object[][] contents =
{
{ "firstDayOfWeek", new Integer(Calendar.MONDAY) },
{ "minimalDaysInFirstWeek", new Integer(4) },
};
/**
* This method returns the object array of key, value pairs containing
* the data for this bundle.
*
* @return The key, value information.
*/
public Object[][] getContents()
{
return contents;
}
}
/* Calendar_en.java -- English calendar locale data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package gnu.java.locale;
import java.util.ListResourceBundle;
import java.util.Calendar;
/**
* This class contains locale data for java.util.Calendar specific for
* english language.
* @author Jochen Hoenicke
*/
public class Calendar_en extends ListResourceBundle
{
/**
* This is the object array used to hold the keys and values
* for this bundle
*/
private static final Object[][] contents =
{
/* Use default values. */
};
/**
* This method returns the object array of key, value pairs containing
* the data for this bundle.
*
* @return The key, value information.
*/
public Object[][] getContents()
{
return contents;
}
}
/* Calendar_nl.java -- Dutch calendar locale data
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package gnu.java.locale;
import java.util.ListResourceBundle;
import java.util.Calendar;
/**
* This class contains locale data for java.util.Calendar specific for
* dutch language.
* @author Mark Wielaard
*/
public class Calendar_nl extends ListResourceBundle
{
/**
* This is the object array used to hold the keys and values
* for this bundle
*/
private static final Object[][] contents =
{
{ "firstDayOfWeek", new Integer(Calendar.MONDAY) },
/* XXX - I guess the default for gregorianCutover
* is also true for the Netherlands. But is it?
*/
};
/**
* This method returns the object array of key, value pairs containing
* the data for this bundle.
*
* @return The key, value information.
*/
public Object[][] getContents()
{
return contents;
}
}
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation /* ClassNotFoundException.java -- exception thrown when attempting to load
a class when no definition for the class can be found.
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of libgcj. This file is part of GNU Classpath.
This software is copyrighted work licensed under the terms of the GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.lang; package java.lang;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
/** /**
* @author Warren Levy <warrenl@cygnus.com> * Exceptions may be thrown by one part of a Java program and caught
* @date September 18, 1998. * by another in order to deal with exceptional conditions. This
* exception can by thrown by specific methods of <code>ClassLoader</code>
* and <code>Class</code> when attempting to load a class when no definition
* for the specified class can be found.
*
* @since JDK 1.0
*
* @author Brian Jones
*/ */
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
* "The Java Language Specification", ISBN 0-201-63451-1
* plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
* Status: Believed complete and correct.
*/
public class ClassNotFoundException extends Exception public class ClassNotFoundException extends Exception
{ {
// TODO12: static final long serialVersionUID = 9176873029745254542L;
// Throwable ex;
private Throwable ex = null;
/**
* Create an exception without a message.
*/
public ClassNotFoundException() public ClassNotFoundException()
{ {
super(); super();
} }
// TODO12: /**
// public ClassNotFoundException(String msg, Throwable ex) * Create an exception with a message.
// { */
// FIXME: Set 'ex' here. public ClassNotFoundException(String s)
// } {
super(s);
public ClassNotFoundException(String msg) }
{
super(msg); /**
} * Create an exception with a message and include the exception
* which occurred while loading the class.
// TODO12: *
// public Throwable getException() * @param ex the exception which occurred while loading the class
// { *
// } * @since JDK 1.2
*/
// TBD: if this needs to be implemented public ClassNotFoundException(String s, Throwable ex)
// public void printStackTrace() {
// { super(s);
// } this.ex = ex;
}
// TBD: if this needs to be implemented
// public void printStackTrace(PrintStream ps) /**
// { * Returns the exception which occurred while loading the class,
// } * otherwise returns null.
*
// TBD: if this needs to be implemented * @since JDK 1.2
// public void printStackTrace(PrintWriter pw) */
// { public Throwable getException()
// } {
return ex;
}
/**
* Print a stack trace of the exception that occurred.
*/
public void printStackTrace()
{
if (ex == null)
{
super.printStackTrace();
}
else
{
ex.printStackTrace();
}
}
/**
* Print a stack trace of the exception that occurred to
* the specified <code>PrintStream</code>.
*/
public void printStackTrace(PrintStream ps)
{
if (ex == null)
{
super.printStackTrace(ps);
}
else
{
ex.printStackTrace(ps);
}
}
/**
* Print a stack trace of the exception that occurred to
* the specified <code>PrintWriter</code>.
*/
public void printStackTrace(PrintWriter pw)
{
if (ex == null)
{
super.printStackTrace(pw);
}
else
{
ex.printStackTrace(pw);
}
}
/**
* Serialize the object in a manner binary compatible with the JDK 1.2
*/
private void writeObject(java.io.ObjectOutputStream s)
throws IOException
{
ObjectOutputStream.PutField oFields;
oFields = s.putFields();
oFields.put("ex", this.ex);
s.writeFields();
}
/**
* Deserialize the object in a manner binary compatible with the JDK 1.2
*/
private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField oFields;
oFields = s.readFields();
ex = (Throwable)oFields.get("ex", (Throwable)null);
}
} }
...@@ -29,8 +29,9 @@ package java.math; ...@@ -29,8 +29,9 @@ package java.math;
import java.math.BigInteger; import java.math.BigInteger;
public class BigDecimal extends Number implements Comparable { public class BigDecimal extends Number implements Comparable {
BigInteger num; private BigInteger intVal;
int scale; private int scale;
private static final long serialVersionUID = 6108874887143696463L;
private final static BigDecimal ZERO = private final static BigDecimal ZERO =
new BigDecimal (BigInteger.valueOf (0), 0); new BigDecimal (BigInteger.valueOf (0), 0);
...@@ -56,7 +57,7 @@ public class BigDecimal extends Number implements Comparable { ...@@ -56,7 +57,7 @@ public class BigDecimal extends Number implements Comparable {
{ {
if (scale < 0) if (scale < 0)
throw new NumberFormatException ("scale of " + scale + " is < 0"); throw new NumberFormatException ("scale of " + scale + " is < 0");
this.num = num; this.intVal = num;
this.scale = scale; this.scale = scale;
} }
...@@ -68,7 +69,7 @@ public class BigDecimal extends Number implements Comparable { ...@@ -68,7 +69,7 @@ public class BigDecimal extends Number implements Comparable {
public BigDecimal (String num) throws NumberFormatException public BigDecimal (String num) throws NumberFormatException
{ {
int point = num.indexOf('.'); int point = num.indexOf('.');
this.num = new BigInteger (point == -1 ? num : this.intVal = new BigInteger (point == -1 ? num :
num.substring (0, point) + num.substring (0, point) +
num.substring (point + 1)); num.substring (point + 1));
scale = num.length() - (point == -1 ? num.length () : point + 1); scale = num.length() - (point == -1 ? num.length () : point + 1);
...@@ -99,8 +100,8 @@ public class BigDecimal extends Number implements Comparable { ...@@ -99,8 +100,8 @@ public class BigDecimal extends Number implements Comparable {
// For addition, need to line up decimals. Note that the movePointRight // For addition, need to line up decimals. Note that the movePointRight
// method cannot be used for this as it might return a BigDecimal with // method cannot be used for this as it might return a BigDecimal with
// scale == 0 instead of the scale we need. // scale == 0 instead of the scale we need.
BigInteger op1 = num; BigInteger op1 = intVal;
BigInteger op2 = val.num; BigInteger op2 = val.intVal;
if (scale < val.scale) if (scale < val.scale)
op1 = op1.multiply (BigInteger.valueOf (10).pow (val.scale - scale)); op1 = op1.multiply (BigInteger.valueOf (10).pow (val.scale - scale));
else if (scale > val.scale) else if (scale > val.scale)
...@@ -116,7 +117,7 @@ public class BigDecimal extends Number implements Comparable { ...@@ -116,7 +117,7 @@ public class BigDecimal extends Number implements Comparable {
public BigDecimal multiply (BigDecimal val) public BigDecimal multiply (BigDecimal val)
{ {
return new BigDecimal (num.multiply (val.num), scale + val.scale); return new BigDecimal (intVal.multiply (val.intVal), scale + val.scale);
} }
public BigDecimal divide (BigDecimal val, int roundingMode) public BigDecimal divide (BigDecimal val, int roundingMode)
...@@ -135,13 +136,13 @@ public class BigDecimal extends Number implements Comparable { ...@@ -135,13 +136,13 @@ public class BigDecimal extends Number implements Comparable {
if (scale < 0) if (scale < 0)
throw new ArithmeticException ("scale is negative: " + scale); throw new ArithmeticException ("scale is negative: " + scale);
if (num.signum () == 0) // handle special case of 0.0/0.0 if (intVal.signum () == 0) // handle special case of 0.0/0.0
return ZERO; return ZERO;
BigInteger dividend = num.multiply (BigInteger.valueOf (10).pow BigInteger dividend = intVal.multiply (BigInteger.valueOf (10).pow
(newScale + 1 - (scale - val.scale))); (newScale + 1 - (scale - val.scale)));
BigInteger parts[] = dividend.divideAndRemainder (val.num); BigInteger parts[] = dividend.divideAndRemainder (val.intVal);
// System.out.println("int: " + parts[0]); // System.out.println("int: " + parts[0]);
// System.out.println("rem: " + parts[1]); // System.out.println("rem: " + parts[1]);
...@@ -194,12 +195,12 @@ public class BigDecimal extends Number implements Comparable { ...@@ -194,12 +195,12 @@ public class BigDecimal extends Number implements Comparable {
public int compareTo (BigDecimal val) public int compareTo (BigDecimal val)
{ {
if (scale == val.scale) if (scale == val.scale)
return num.compareTo (val.num); return intVal.compareTo (val.intVal);
BigInteger thisParts[] = BigInteger thisParts[] =
num.divideAndRemainder (BigInteger.valueOf (10).pow (scale)); intVal.divideAndRemainder (BigInteger.valueOf (10).pow (scale));
BigInteger valParts[] = BigInteger valParts[] =
val.num.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale)); val.intVal.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale));
int compare; int compare;
if ((compare = thisParts[0].compareTo (valParts[0])) != 0) if ((compare = thisParts[0].compareTo (valParts[0])) != 0)
...@@ -263,7 +264,7 @@ public class BigDecimal extends Number implements Comparable { ...@@ -263,7 +264,7 @@ public class BigDecimal extends Number implements Comparable {
public BigDecimal movePointLeft (int n) public BigDecimal movePointLeft (int n)
{ {
return (n < 0) ? movePointRight (-n) : new BigDecimal (num, scale + n); return (n < 0) ? movePointRight (-n) : new BigDecimal (intVal, scale + n);
} }
public BigDecimal movePointRight (int n) public BigDecimal movePointRight (int n)
...@@ -272,15 +273,15 @@ public class BigDecimal extends Number implements Comparable { ...@@ -272,15 +273,15 @@ public class BigDecimal extends Number implements Comparable {
return movePointLeft (-n); return movePointLeft (-n);
if (scale >= n) if (scale >= n)
return new BigDecimal (num, scale - n); return new BigDecimal (intVal, scale - n);
return new BigDecimal (num.multiply return new BigDecimal (intVal.multiply
(BigInteger.valueOf (10).pow (n - scale)), 0); (BigInteger.valueOf (10).pow (n - scale)), 0);
} }
public int signum () public int signum ()
{ {
return num.signum (); return intVal.signum ();
} }
public int scale () public int scale ()
...@@ -290,17 +291,17 @@ public class BigDecimal extends Number implements Comparable { ...@@ -290,17 +291,17 @@ public class BigDecimal extends Number implements Comparable {
public BigDecimal abs () public BigDecimal abs ()
{ {
return new BigDecimal (num.abs (), scale); return new BigDecimal (intVal.abs (), scale);
} }
public BigDecimal negate () public BigDecimal negate ()
{ {
return new BigDecimal (num.negate (), scale); return new BigDecimal (intVal.negate (), scale);
} }
public String toString () public String toString ()
{ {
String bigStr = num.toString(); String bigStr = intVal.toString();
if (scale == 0) if (scale == 0)
return bigStr; return bigStr;
...@@ -322,7 +323,8 @@ public class BigDecimal extends Number implements Comparable { ...@@ -322,7 +323,8 @@ public class BigDecimal extends Number implements Comparable {
public BigInteger toBigInteger () public BigInteger toBigInteger ()
{ {
return scale == 0 ? num : num.divide (BigInteger.valueOf (10).pow (scale)); return scale == 0 ? intVal :
intVal.divide (BigInteger.valueOf (10).pow (scale));
} }
......
...@@ -11,6 +11,9 @@ details. */ ...@@ -11,6 +11,9 @@ details. */
package java.math; package java.math;
import gnu.gcj.math.*; import gnu.gcj.math.*;
import java.util.Random; import java.util.Random;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
/** /**
* @author Warren Levy <warrenl@cygnus.com> * @author Warren Levy <warrenl@cygnus.com>
...@@ -35,8 +38,17 @@ public class BigInteger extends Number implements Comparable ...@@ -35,8 +38,17 @@ public class BigInteger extends Number implements Comparable
* If words == null, the ival is the value of this BigInteger. * If words == null, the ival is the value of this BigInteger.
* Otherwise, the first ival elements of words make the value * Otherwise, the first ival elements of words make the value
* of this BigInteger, stored in little-endian order, 2's-complement form. */ * of this BigInteger, stored in little-endian order, 2's-complement form. */
private int ival; transient private int ival;
private int[] words; transient private int[] words;
// Serialization fields.
private int bitCount = -1;
private int bitLength = -1;
private int firstNonzeroByteNum = -2;
private int lowestSetBit = -2;
private byte[] magnitude;
private int signum;
private static final long serialVersionUID = -8287574255936472291L;
/** We pre-allocate integers in the range minFixNum..maxFixNum. */ /** We pre-allocate integers in the range minFixNum..maxFixNum. */
...@@ -2201,4 +2213,22 @@ public class BigInteger extends Number implements Comparable ...@@ -2201,4 +2213,22 @@ public class BigInteger extends Number implements Comparable
} }
return isNegative() ? x_len * 32 - i : i; return isNegative() ? x_len * 32 - i : i;
} }
private void readObject(ObjectInputStream s)
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;
}
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException
{
signum = signum();
magnitude = toByteArray();
s.defaultWriteObject();
}
} }
...@@ -174,4 +174,5 @@ public final class BitSet implements Cloneable, Serializable ...@@ -174,4 +174,5 @@ public final class BitSet implements Cloneable, Serializable
// The actual bits. // The actual bits.
private long[] bits; private long[] bits;
private static final long serialVersionUID = 7997698588986878753L;
} }
/* Copyright (C) 1998, 1999 Free Software Foundation /* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -93,17 +93,17 @@ public class GregorianCalendar extends Calendar { ...@@ -93,17 +93,17 @@ public class GregorianCalendar extends Calendar {
public GregorianCalendar () public GregorianCalendar ()
{ {
this(null, null); this(TimeZone.getDefault (), Locale.getDefault ());
} }
public GregorianCalendar (TimeZone zone) public GregorianCalendar (TimeZone zone)
{ {
this (zone, null); this (zone, Locale.getDefault ());
} }
public GregorianCalendar (Locale locale) public GregorianCalendar (Locale locale)
{ {
this (null, locale); this (TimeZone.getDefault (), locale);
} }
public GregorianCalendar (TimeZone zone, Locale locale) public GregorianCalendar (TimeZone zone, Locale locale)
......
...@@ -26,6 +26,7 @@ public final class Locale implements java.io.Serializable, Cloneable ...@@ -26,6 +26,7 @@ public final class Locale implements java.io.Serializable, Cloneable
private String language; private String language;
private String variant; private String variant;
private static Locale defaultLocale; private static Locale defaultLocale;
private static final long serialVersionUID = 9149081749638150636L;
// These are as specified in the JDK 1.2 AP documentation // These are as specified in the JDK 1.2 AP documentation
...@@ -145,4 +146,28 @@ public final class Locale implements java.io.Serializable, Cloneable ...@@ -145,4 +146,28 @@ public final class Locale implements java.io.Serializable, Cloneable
} }
return result.toString(); return result.toString();
} }
/**
* @serialdata According to jdk1.2 the hashcode should always be
* written as -1;
*/
private void writeObject(java.io.ObjectOutputStream output)
throws java.io.IOException
{
int tmpHashcode = hashcode;
hashcode = -1;
output.defaultWriteObject();
hashcode = tmpHashcode;
}
/**
* @serialdata According to jdk1.2 the hashCode is always invalid
* and must be recomputed.
*/
private void readObject(java.io.ObjectInputStream input)
throws java.io.IOException, ClassNotFoundException
{
input.defaultReadObject();
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment