Commit bc6ccd33 by Warren Levy Committed by Warren Levy

PropertyChangeEvent.java (serialVersionUID): Added.

	* java/beans/PropertyChangeEvent.java (serialVersionUID): Added.
	* java/beans/PropertyVetoException.java (serialVersionUID): Added.
	* java/io/File.java (writeObject): Added.
	(readObject): Added.
	(serialVersionUID): Added.
	* java/io/ObjectOutputStream.java (writeObject): Initialized
	fieldsAlreadyWritten before recursion rather than after.
	* java/io/ObjectStreamClass.java (serialVersionUID): Added.
	* java/io/OptionalDataException.java (serialVersionUID): Added.
	(OptionalDataException): Made package private.
	* java/io/SyncFailedException.java (SyncFailedException): Removed
	default constructor to match spec.
	* java/lang/Boolean.java (serialVersionUID): Added.
	* java/lang/Byte.java (serialVersionUID): Added.
	* java/lang/Character.java (serialVersionUID): Added.
	* java/lang/Double.java (serialVersionUID): Added.
	* java/lang/Float.java (serialVersionUID): Added.
	* java/lang/Integer.java (serialVersionUID): Added.
	* java/lang/Long.java (serialVersionUID): Added.
	* java/lang/Number.java (serialVersionUID): Added.
	* java/lang/Short.java (serialVersionUID): Added.
	* java/lang/String.java (serialVersionUID): Added.
	* java/lang/ThreadDeath.java (ThreadDeath): Removed constructor
	to match spec.
	* java/lang/reflect/InvocationTargetException.java
	(serialVersionUID): Added.
	* java/net/URL.java (handler): Made transient.
	(hashCode): Added field for serialization, per spec. and use
	cached value if available.
	(serialVersionUID): Added.
	(URL): Initialize hashCode.
	(set): Adjust hashCode.
	(readObject): New Method to initialize the protocol handler when
	deserializing.
	(writeObject): New method.
	* java/text/BreakIterator.java: Removed 'implements Serializable'.
	* java/text/Collator.java: Removed 'implements Serializable'.
	* java/util/GregorianCalendar.java (serialVersionUID): Added.
	* java/util/Properties.java (serialVersionUID): Added.
	* java/util/Random.java (serialVersionUID): Added.
	(seed): Made private.
	(nextNextGaussian): Made private.
	(haveNextNextGaussian): Made private.
	* java/util/Stack.java (serialVersionUID): Added.
	* java/util/TimeZone.java (serialVersionUID): Added.
	* java/util/Vector.java (serialVersionUID): Added.

Serialization mods.

From-SVN: r36272
parent 759e8187
2000-09-08 Warren Levy <warrenl@cygnus.com>
* java/beans/PropertyChangeEvent.java (serialVersionUID): Added.
* java/beans/PropertyVetoException.java (serialVersionUID): Added.
* java/io/File.java (writeObject): Added.
(readObject): Added.
(serialVersionUID): Added.
* java/io/ObjectOutputStream.java (writeObject): Initialized
fieldsAlreadyWritten before recursion rather than after.
* java/io/ObjectStreamClass.java (serialVersionUID): Added.
* java/io/OptionalDataException.java (serialVersionUID): Added.
(OptionalDataException): Made package private.
* java/io/SyncFailedException.java (SyncFailedException): Removed
default constructor to match spec.
* java/lang/Boolean.java (serialVersionUID): Added.
* java/lang/Byte.java (serialVersionUID): Added.
* java/lang/Character.java (serialVersionUID): Added.
* java/lang/Double.java (serialVersionUID): Added.
* java/lang/Float.java (serialVersionUID): Added.
* java/lang/Integer.java (serialVersionUID): Added.
* java/lang/Long.java (serialVersionUID): Added.
* java/lang/Number.java (serialVersionUID): Added.
* java/lang/Short.java (serialVersionUID): Added.
* java/lang/String.java (serialVersionUID): Added.
* java/lang/ThreadDeath.java (ThreadDeath): Removed constructor
to match spec.
* java/lang/reflect/InvocationTargetException.java
(serialVersionUID): Added.
* java/net/URL.java (handler): Made transient.
(hashCode): Added field for serialization, per spec. and use
cached value if available.
(serialVersionUID): Added.
(URL): Initialize hashCode.
(set): Adjust hashCode.
(readObject): New Method to initialize the protocol handler when
deserializing.
(writeObject): New method.
* java/text/BreakIterator.java: Removed 'implements Serializable'.
* java/text/Collator.java: Removed 'implements Serializable'.
* java/util/GregorianCalendar.java (serialVersionUID): Added.
* java/util/Properties.java (serialVersionUID): Added.
* java/util/Random.java (serialVersionUID): Added.
(seed): Made private.
(nextNextGaussian): Made private.
(haveNextNextGaussian): Made private.
* java/util/Stack.java (serialVersionUID): Added.
* java/util/TimeZone.java (serialVersionUID): Added.
* java/util/Vector.java (serialVersionUID): Added.
2000-09-07 Bryce McKinlay <bryce@albatross.co.nz> 2000-09-07 Bryce McKinlay <bryce@albatross.co.nz>
* Makefile.am (Thread.h): Don't be friends with native threads * Makefile.am (Thread.h): Don't be friends with native threads
......
...@@ -54,6 +54,8 @@ public class PropertyChangeEvent extends java.util.EventObject { ...@@ -54,6 +54,8 @@ public class PropertyChangeEvent extends java.util.EventObject {
Object newValue; Object newValue;
Object propagationId; Object propagationId;
private static final long serialVersionUID = 7042693688939648123L;
/** Create a new PropertyChangeEvent. Remember that if /** Create a new PropertyChangeEvent. Remember that if
** you received a PropertyChangeEvent and are sending ** you received a PropertyChangeEvent and are sending
** a new one, you should also set the propagation ID ** a new one, you should also set the propagation ID
......
...@@ -39,6 +39,8 @@ package java.beans; ...@@ -39,6 +39,8 @@ package java.beans;
public class PropertyVetoException extends Exception { public class PropertyVetoException extends Exception {
PropertyChangeEvent evt; PropertyChangeEvent evt;
private static final long serialVersionUID = 129596057694162164L;
/** Instantiate this exception with the given message and property change. /** Instantiate this exception with the given message and property change.
** @param msg the reason for the veto. ** @param msg the reason for the veto.
** @param changeEvent the PropertyChangeEvent that was thrown. ** @param changeEvent the PropertyChangeEvent that was thrown.
......
...@@ -388,6 +388,24 @@ public class File implements Serializable ...@@ -388,6 +388,24 @@ public class File implements Serializable
FileDeleter.add (this); FileDeleter.add (this);
} }
private void writeObject (ObjectOutputStream oos) throws IOException
{
oos.defaultWriteObject ();
oos.writeChar (separatorChar);
}
private void readObject (ObjectInputStream ois)
throws ClassNotFoundException, IOException
{
ois.defaultReadObject ();
// If the file was from an OS with a different dir separator,
// fixup the path to use the separator on this OS.
char oldSeparatorChar = ois.readChar ();
if (oldSeparatorChar != separatorChar)
path = path.replace (oldSeparatorChar, separatorChar);
}
// QUERY arguments to access function. // QUERY arguments to access function.
private final static int READ = 0; private final static int READ = 0;
private final static int WRITE = 1; private final static int WRITE = 1;
...@@ -404,4 +422,6 @@ public class File implements Serializable ...@@ -404,4 +422,6 @@ public class File implements Serializable
private final native long attr (String p, int query); private final native long attr (String p, int query);
private final native boolean access (String p, int query); private final native boolean access (String p, int query);
private final native boolean stat (String p, int query); private final native boolean stat (String p, int query);
private static final long serialVersionUID = 301077366599181567L;
} }
...@@ -313,12 +313,12 @@ public class ObjectOutputStream extends OutputStream ...@@ -313,12 +313,12 @@ public class ObjectOutputStream extends OutputStream
{ {
currentObjectStreamClass = hierarchy[i]; currentObjectStreamClass = hierarchy[i];
fieldsAlreadyWritten = false;
has_write = currentObjectStreamClass.hasWriteMethod (); has_write = currentObjectStreamClass.hasWriteMethod ();
writeFields (obj, currentObjectStreamClass.fields, writeFields (obj, currentObjectStreamClass.fields,
has_write); has_write);
fieldsAlreadyWritten = false;
if (has_write) if (has_write)
{ {
drain (); drain ();
......
...@@ -635,6 +635,10 @@ public class ObjectStreamClass implements Serializable ...@@ -635,6 +635,10 @@ public class ObjectStreamClass implements Serializable
// these are accessed by ObjectIn/OutputStream // these are accessed by ObjectIn/OutputStream
int primFieldSize = -1; // -1 if not yet calculated int primFieldSize = -1; // -1 if not yet calculated
int objectFieldCount; int objectFieldCount;
// This is probably not necessary because this class is special cased already
// but it will avoid showing up as a discrepancy when comparing SUIDs.
private static final long serialVersionUID = -6120832682080437368L;
} }
......
...@@ -23,12 +23,16 @@ public class OptionalDataException extends ObjectStreamException ...@@ -23,12 +23,16 @@ public class OptionalDataException extends ObjectStreamException
public boolean eof; public boolean eof;
public int length; public int length;
public OptionalDataException() // FIXME: This can probably go away once the right signatures of
// these package private constructors is determined.
private static final long serialVersionUID = -8011121865681257820L;
OptionalDataException()
{ {
super(); super();
} }
public OptionalDataException(String msg) OptionalDataException(String msg)
{ {
super(msg); super(msg);
} }
......
...@@ -22,11 +22,6 @@ package java.io; ...@@ -22,11 +22,6 @@ package java.io;
public class SyncFailedException extends IOException public class SyncFailedException extends IOException
{ {
public SyncFailedException ()
{
super ();
}
public SyncFailedException (String s) public SyncFailedException (String s)
{ {
super (s); super (s);
......
/* 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.
...@@ -32,6 +32,8 @@ public final class Boolean extends Object implements Serializable ...@@ -32,6 +32,8 @@ public final class Boolean extends Object implements Serializable
/* The boolean value of the instance. */ /* The boolean value of the instance. */
private boolean value; private boolean value;
private static final long serialVersionUID = -3665804199014368530L;
public Boolean(boolean boolVal) public Boolean(boolean boolVal)
{ {
value = boolVal; value = boolVal;
......
/* 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.
...@@ -29,6 +29,8 @@ public final class Byte extends Number implements Comparable ...@@ -29,6 +29,8 @@ public final class Byte extends Number implements Comparable
// by javac, and is handled specially by gcc. // by javac, and is handled specially by gcc.
public static final Class TYPE = byte.class; public static final Class TYPE = byte.class;
private static final long serialVersionUID = -7183698231559129828L;
public Byte(byte value) public Byte(byte value)
{ {
this.value = value; this.value = value;
......
// Character.java - Character class. // Character.java - Character class.
/* 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.
...@@ -83,6 +83,7 @@ public final class Character implements Serializable, Comparable ...@@ -83,6 +83,7 @@ public final class Character implements Serializable, Comparable
public static final byte PRIVATE_USE = 18; public static final byte PRIVATE_USE = 18;
public static final byte SURROGATE = 19; public static final byte SURROGATE = 19;
private static final long serialVersionUID = 3786198910865385080L;
public Character (char ch) public Character (char ch)
{ {
......
...@@ -32,6 +32,8 @@ public final class Double extends Number ...@@ -32,6 +32,8 @@ public final class Double extends Number
private double value; private double value;
private static final long serialVersionUID = -9172774392245257468L;
public native static double parseDouble (String s) public native static double parseDouble (String s)
throws NumberFormatException; throws NumberFormatException;
......
/* 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.
...@@ -32,6 +32,8 @@ public final class Float extends Number ...@@ -32,6 +32,8 @@ public final class Float extends Number
private float value; private float value;
private static final long serialVersionUID = -2671257302660747028L;
public Float (float value) public Float (float value)
{ {
this.value = value; this.value = value;
......
/* 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.
...@@ -30,6 +30,8 @@ public final class Integer extends Number implements Comparable ...@@ -30,6 +30,8 @@ public final class Integer extends Number implements Comparable
/* The int value of the instance. */ /* The int value of the instance. */
private int value; private int value;
private static final long serialVersionUID = 1360826667806852920L;
public Integer(int val) public Integer(int val)
{ {
value = val; value = val;
......
/* 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.
...@@ -30,6 +30,8 @@ public final class Long extends Number implements Comparable ...@@ -30,6 +30,8 @@ public final class Long extends Number implements Comparable
/* The long value of the instance. */ /* The long value of the instance. */
private long value; private long value;
private static final long serialVersionUID = 4290774380558885855L;
public Long(long val) public Long(long val)
{ {
value = val; value = val;
......
/* 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.
...@@ -36,4 +36,6 @@ public abstract class Number implements Serializable ...@@ -36,4 +36,6 @@ public abstract class Number implements Serializable
{ {
return (short) intValue(); return (short) intValue();
} }
private static final long serialVersionUID = -8742448824652078965L;
} }
/* 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.
...@@ -29,6 +29,8 @@ public final class Short extends Number implements Comparable ...@@ -29,6 +29,8 @@ public final class Short extends Number implements Comparable
// by javac, and is handled specially by gcc. // by javac, and is handled specially by gcc.
public static final Class TYPE = short.class; public static final Class TYPE = short.class;
private static final long serialVersionUID = 7515723908773894738L;
public Short(short value) public Short(short value)
{ {
this.value = value; this.value = value;
......
...@@ -26,6 +26,10 @@ public final class String implements Serializable, Comparable ...@@ -26,6 +26,10 @@ public final class String implements Serializable, Comparable
private int boffset; // Note this is a byte offset - don't use in Java code! private int boffset; // Note this is a byte offset - don't use in Java code!
private int count; private int count;
// This is probably not necessary because this class is special cased already
// but it will avoid showing up as a discrepancy when comparing SUIDs.
private static final long serialVersionUID = -6849794470754667710L;
public String () public String ()
{ {
init(); init();
......
// ThreadDeath.java - Special exception registering Thread death. // ThreadDeath.java - Special exception registering Thread death.
/* 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.
...@@ -27,9 +27,4 @@ public class ThreadDeath extends Error ...@@ -27,9 +27,4 @@ public class ThreadDeath extends Error
{ {
super (); super ();
} }
public ThreadDeath (String message)
{
super (message);
}
} }
// InvocationTargetException.java - Wrapper exception for reflection. // InvocationTargetException.java - Wrapper exception for reflection.
/* 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.
...@@ -70,4 +70,6 @@ public class InvocationTargetException extends Exception ...@@ -70,4 +70,6 @@ public class InvocationTargetException extends Exception
// The wrapped exception. The name is specified by the // The wrapped exception. The name is specified by the
// serialization spec. // serialization spec.
private Throwable target; private Throwable target;
private static final long serialVersionUID = 4085088731926701167L;
} }
// URL.java - A Uniform Resource Locator. // URL.java - A Uniform Resource Locator.
/* Copyright (C) 1999 Free Software Foundation /* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -32,10 +32,13 @@ public final class URL implements Serializable ...@@ -32,10 +32,13 @@ public final class URL implements Serializable
private int port = -1; // Initialize for constructor using context. private int port = -1; // Initialize for constructor using context.
private String file; private String file;
private String ref; private String ref;
private URLStreamHandler handler; private int hashCode = 0;
transient private URLStreamHandler handler;
private static Hashtable handlers = new Hashtable(); private static Hashtable handlers = new Hashtable();
private static URLStreamHandlerFactory factory; private static URLStreamHandlerFactory factory;
private static final long serialVersionUID = -7627629688361524110L;
public URL(String protocol, String host, int port, String file) public URL(String protocol, String host, int port, String file)
throws MalformedURLException throws MalformedURLException
{ {
...@@ -90,6 +93,7 @@ public final class URL implements Serializable ...@@ -90,6 +93,7 @@ public final class URL implements Serializable
this.file = file.substring(0, hashAt); this.file = file.substring(0, hashAt);
this.ref = file.substring(hashAt + 1); this.ref = file.substring(hashAt + 1);
} }
hashCode = hashCode(); // Used for serialization.
} }
public URL(String spec) throws MalformedURLException public URL(String spec) throws MalformedURLException
...@@ -181,6 +185,8 @@ public final class URL implements Serializable ...@@ -181,6 +185,8 @@ public final class URL implements Serializable
hashAt < 0 ? spec.length() : hashAt); hashAt < 0 ? spec.length() : hashAt);
if (hashAt >= 0) if (hashAt >= 0)
ref = spec.substring(hashAt + 1); ref = spec.substring(hashAt + 1);
hashCode = hashCode(); // Used for serialization.
} }
public boolean equals(Object obj) public boolean equals(Object obj)
...@@ -249,7 +255,10 @@ public final class URL implements Serializable ...@@ -249,7 +255,10 @@ public final class URL implements Serializable
// (which was reduced to "" with a hashcode of zero). A "" host also // (which was reduced to "" with a hashcode of zero). A "" host also
// causes the port number and the two hashcodes to be summed. // causes the port number and the two hashcodes to be summed.
return (protocol.hashCode() + ((host == null) ? 0 : host.hashCode()) + if (hashCode != 0)
return hashCode; // Use cached value if available.
else
return (protocol.hashCode() + ((host == null) ? 0 : host.hashCode()) +
port + file.hashCode()); port + file.hashCode());
} }
...@@ -290,6 +299,7 @@ public final class URL implements Serializable ...@@ -290,6 +299,7 @@ public final class URL implements Serializable
this.host = host; this.host = host;
this.file = file; this.file = file;
this.ref = ref; this.ref = ref;
hashCode = hashCode(); // Used for serialization.
} }
public static synchronized void public static synchronized void
...@@ -384,4 +394,18 @@ public final class URL implements Serializable ...@@ -384,4 +394,18 @@ public final class URL implements Serializable
return handler; return handler;
} }
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
ois.defaultReadObject();
this.handler = setURLStreamHandler(protocol);
if (this.handler == null)
throw new IOException("Handler for protocol " + protocol + " not found");
}
private void writeObject(ObjectOutputStream oos) throws IOException
{
oos.defaultWriteObject();
}
} }
...@@ -10,7 +10,6 @@ details. */ ...@@ -10,7 +10,6 @@ details. */
package java.text; package java.text;
import java.io.Serializable;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
...@@ -24,7 +23,7 @@ import java.util.ResourceBundle; ...@@ -24,7 +23,7 @@ import java.util.ResourceBundle;
* Status: Believed complete and correct to 1.1. * Status: Believed complete and correct to 1.1.
*/ */
public abstract class BreakIterator implements Cloneable, Serializable public abstract class BreakIterator implements Cloneable
{ {
// The value was discovered by writing a test program. // The value was discovered by writing a test program.
public static final int DONE = -1; public static final int DONE = -1;
......
...@@ -10,7 +10,6 @@ details. */ ...@@ -10,7 +10,6 @@ details. */
package java.text; package java.text;
import java.io.Serializable;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
...@@ -24,7 +23,7 @@ import java.util.ResourceBundle; ...@@ -24,7 +23,7 @@ import java.util.ResourceBundle;
* Status: Mostly complete, but parts stubbed out. Look for FIXME. * Status: Mostly complete, but parts stubbed out. Look for FIXME.
*/ */
public abstract class Collator implements Cloneable, Serializable public abstract class Collator implements Cloneable
{ {
public static final int NO_DECOMPOSITION = 0; public static final int NO_DECOMPOSITION = 0;
public static final int CANONICAL_DECOMPOSITION = 1; public static final int CANONICAL_DECOMPOSITION = 1;
......
...@@ -89,6 +89,8 @@ public class GregorianCalendar extends Calendar { ...@@ -89,6 +89,8 @@ public class GregorianCalendar extends Calendar {
3600000 /* DST_OFFSET */ 3600000 /* DST_OFFSET */
}; };
private static final long serialVersionUID = -8125100834729963327L;
public GregorianCalendar () public GregorianCalendar ()
{ {
this(null, null); this(null, null);
......
...@@ -33,6 +33,8 @@ public class Properties extends Hashtable ...@@ -33,6 +33,8 @@ public class Properties extends Hashtable
{ {
protected Properties defaults; protected Properties defaults;
private static final long serialVersionUID = 4112578634029874840L;
public String getProperty (String propName) public String getProperty (String propName)
{ {
return getProperty (propName, null); return getProperty (propName, null);
......
...@@ -26,15 +26,17 @@ import java.io.Serializable; ...@@ -26,15 +26,17 @@ import java.io.Serializable;
public class Random implements Serializable public class Random implements Serializable
{ {
/* Used by next() to hold the state of the pseudorandom number generator */ /* Used by next() to hold the state of the pseudorandom number generator */
protected long seed; private long seed;
/* Used by nextGaussian() to hold a precomputed value */ /* Used by nextGaussian() to hold a precomputed value */
/* to be delivered by that method the next time it is called */ /* to be delivered by that method the next time it is called */
protected double nextNextGaussian; private double nextNextGaussian;
/* Used by nextGaussian() to keep track of whether it is has precomputed */ /* Used by nextGaussian() to keep track of whether it is has precomputed */
/* and stashed away the next value to be delivered by that method */ /* and stashed away the next value to be delivered by that method */
protected boolean haveNextNextGaussian = false; private boolean haveNextNextGaussian = false;
private static final long serialVersionUID = 3905348978240129619L;
public Random() public Random()
{ {
......
...@@ -71,4 +71,6 @@ public class Stack extends Vector ...@@ -71,4 +71,6 @@ public class Stack extends Vector
return -1; return -1;
} }
private static final long serialVersionUID = 1224463164541339165L;
} }
...@@ -30,6 +30,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable ...@@ -30,6 +30,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
private static TimeZone zoneDefault; private static TimeZone zoneDefault;
private static final long serialVersionUID = 3581463369166924961L;
public TimeZone () public TimeZone ()
{ {
} }
......
...@@ -61,6 +61,8 @@ public class Vector implements Cloneable, Serializable ...@@ -61,6 +61,8 @@ public class Vector implements Cloneable, Serializable
/* The buffer in which elements of this vector are stored */ /* The buffer in which elements of this vector are stored */
protected Object[] elementData; protected Object[] elementData;
private static final long serialVersionUID = -2767605614048989439L;
public Vector() public Vector()
{ {
this(10, 0); this(10, 0);
......
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