PropertyChangeEvent.java (serialVersionUID): Added.
authorWarren Levy <warrenl@cygnus.com>
Fri, 8 Sep 2000 19:37:09 +0000 (19:37 +0000)
committerWarren Levy <warrenl@gcc.gnu.org>
Fri, 8 Sep 2000 19:37:09 +0000 (19:37 +0000)
* 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

29 files changed:
libjava/ChangeLog
libjava/java/beans/PropertyChangeEvent.java
libjava/java/beans/PropertyVetoException.java
libjava/java/io/File.java
libjava/java/io/ObjectOutputStream.java
libjava/java/io/ObjectStreamClass.java
libjava/java/io/OptionalDataException.java
libjava/java/io/SyncFailedException.java
libjava/java/lang/Boolean.java
libjava/java/lang/Byte.java
libjava/java/lang/Character.java
libjava/java/lang/Double.java
libjava/java/lang/Float.java
libjava/java/lang/Integer.java
libjava/java/lang/Long.java
libjava/java/lang/Number.java
libjava/java/lang/Short.java
libjava/java/lang/String.java
libjava/java/lang/ThreadDeath.java
libjava/java/lang/reflect/InvocationTargetException.java
libjava/java/net/URL.java
libjava/java/text/BreakIterator.java
libjava/java/text/Collator.java
libjava/java/util/GregorianCalendar.java
libjava/java/util/Properties.java
libjava/java/util/Random.java
libjava/java/util/Stack.java
libjava/java/util/TimeZone.java
libjava/java/util/Vector.java

index 01ab720..3164f0c 100644 (file)
@@ -1,3 +1,52 @@
+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>
 
        * Makefile.am (Thread.h): Don't be friends with native threads 
index f48d5fe..3dc3478 100644 (file)
@@ -54,6 +54,8 @@ public class PropertyChangeEvent extends java.util.EventObject {
        Object newValue;
        Object propagationId;
 
+       private static final long serialVersionUID = 7042693688939648123L;
+
        /** Create a new PropertyChangeEvent.  Remember that if
         ** you received a PropertyChangeEvent and are sending
         ** a new one, you should also set the propagation ID
index 989b9e0..daad010 100644 (file)
@@ -39,6 +39,8 @@ package java.beans;
 public class PropertyVetoException extends Exception {
        PropertyChangeEvent evt;
 
+       private static final long serialVersionUID = 129596057694162164L;
+
        /** Instantiate this exception with the given message and property change.
         ** @param msg the reason for the veto.
         ** @param changeEvent the PropertyChangeEvent that was thrown.
index 01d8d53..fc3477c 100644 (file)
@@ -388,6 +388,24 @@ public class File implements Serializable
     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.
   private final static int READ = 0;
   private final static int WRITE = 1;
@@ -404,4 +422,6 @@ public class File implements Serializable
   private final native long attr (String p, int query);
   private final native boolean access (String p, int query);
   private final native boolean stat (String p, int query);
+
+  private static final long serialVersionUID = 301077366599181567L;
 }
index c4ffc8c..664b882 100644 (file)
@@ -313,12 +313,12 @@ public class ObjectOutputStream extends OutputStream
          {
            currentObjectStreamClass = hierarchy[i];
 
+           fieldsAlreadyWritten = false;
            has_write = currentObjectStreamClass.hasWriteMethod ();
+
            writeFields (obj, currentObjectStreamClass.fields,
                         has_write);
 
-           fieldsAlreadyWritten = false;
-
            if (has_write)
            {
              drain ();
index 5bd867f..085c72b 100644 (file)
@@ -635,6 +635,10 @@ public class ObjectStreamClass implements Serializable
   // these are accessed by ObjectIn/OutputStream
   int primFieldSize = -1;  // -1 if not yet calculated
   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;
 }
 
 
index eabda73..ed4624b 100644 (file)
@@ -23,12 +23,16 @@ public class OptionalDataException extends ObjectStreamException
   public boolean eof;
   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();
   }
 
-  public OptionalDataException(String msg)
+  OptionalDataException(String msg)
   {
     super(msg);
   }
index 05f4c3d..964d24a 100644 (file)
@@ -22,11 +22,6 @@ package java.io;
 
 public class SyncFailedException extends IOException
 {
-  public SyncFailedException ()
-  {
-    super ();
-  }
-
   public SyncFailedException (String s)
   {
     super (s);
index 041f725..027fd24 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -32,6 +32,8 @@ public final class Boolean extends Object implements Serializable
   /* The boolean value of the instance. */
   private boolean value;
 
+  private static final long serialVersionUID = -3665804199014368530L;
+
   public Boolean(boolean boolVal)
   {
     value = boolVal;
index 95db094..78f34aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -29,6 +29,8 @@ public final class Byte extends Number implements Comparable
   // by javac, and is handled specially by gcc.
   public static final Class TYPE = byte.class;
 
+  private static final long serialVersionUID = -7183698231559129828L;
+
   public Byte(byte value)
   {
     this.value = value;
index 4306afb..2695b04 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -83,6 +83,7 @@ public final class Character implements Serializable, Comparable
   public static final byte PRIVATE_USE = 18;
   public static final byte SURROGATE   = 19;
 
+  private static final long serialVersionUID = 3786198910865385080L;
 
   public Character (char ch)
   {
index cb8fd95..10e9093 100644 (file)
@@ -32,6 +32,8 @@ public final class Double extends Number
 
   private double value;
 
+  private static final long serialVersionUID = -9172774392245257468L;
+
   public native static double parseDouble (String s) 
     throws NumberFormatException;
 
index 63c6fa1..b5939de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -32,6 +32,8 @@ public final class Float extends Number
 
   private float value;
 
+  private static final long serialVersionUID = -2671257302660747028L;
+
   public Float (float value)
   {
     this.value = value;
index feb7785..163c850 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -30,6 +30,8 @@ public final class Integer extends Number implements Comparable
   /* The int value of the instance. */
   private int value;
 
+  private static final long serialVersionUID = 1360826667806852920L;
+
   public Integer(int val)
   {
     value = val;
index 95f426d..e6872db 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -30,6 +30,8 @@ public final class Long extends Number implements Comparable
   /* The long value of the instance. */
   private long value;
 
+  private static final long serialVersionUID = 4290774380558885855L;
+
   public Long(long val)
   {
     value = val;
index 9fa0566..92d98af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -36,4 +36,6 @@ public abstract class Number implements Serializable
   {
     return (short) intValue();
   }
+
+  private static final long serialVersionUID = -8742448824652078965L;
 }
index a8bd965..6733607 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -29,6 +29,8 @@ public final class Short extends Number implements Comparable
   // by javac, and is handled specially by gcc.
   public static final Class TYPE = short.class;
 
+  private static final long serialVersionUID = 7515723908773894738L;
+
   public Short(short value)
   {
     this.value = value;
index 12f8789..9937374 100644 (file)
@@ -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 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 ()
   {
     init();
index d02c2fc..ae0e3fb 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -27,9 +27,4 @@ public class ThreadDeath extends Error
   {
     super ();
   }
-
-  public ThreadDeath (String message)
-  {
-    super (message);
-  }
 }
index 3d59506..0152a7b 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -70,4 +70,6 @@ public class InvocationTargetException extends Exception
   // The wrapped exception.  The name is specified by the
   // serialization spec.
   private Throwable target;
+
+  private static final long serialVersionUID = 4085088731926701167L;
 }
index 5931eef..2583732 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
 
@@ -32,10 +32,13 @@ public final class URL implements Serializable
   private int port = -1;       // Initialize for constructor using context.
   private String file;
   private String ref;
-  private URLStreamHandler handler;
+  private int hashCode = 0;
+  transient private URLStreamHandler handler;
   private static Hashtable handlers = new Hashtable();
   private static URLStreamHandlerFactory factory;
 
+  private static final long serialVersionUID = -7627629688361524110L;
+
   public URL(String protocol, String host, int port, String file)
     throws MalformedURLException
   {
@@ -90,6 +93,7 @@ public final class URL implements Serializable
        this.file = file.substring(0, hashAt);
        this.ref = file.substring(hashAt + 1);
       }
+    hashCode = hashCode();                     // Used for serialization.
   }
 
   public URL(String spec) throws MalformedURLException
@@ -181,6 +185,8 @@ public final class URL implements Serializable
                          hashAt < 0 ? spec.length() : hashAt);
     if (hashAt >= 0)
       ref = spec.substring(hashAt + 1);
+
+    hashCode = hashCode();                     // Used for serialization.
   }
 
   public boolean equals(Object obj)
@@ -249,7 +255,10 @@ public final class URL implements Serializable
     // (which was reduced to "" with a hashcode of zero).  A "" host also
     // 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());
   }
 
@@ -290,6 +299,7 @@ public final class URL implements Serializable
     this.host = host;
     this.file = file;
     this.ref = ref;
+    hashCode = hashCode();                     // Used for serialization.
   }
 
   public static synchronized void
@@ -384,4 +394,18 @@ public final class URL implements Serializable
 
     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();
+  }
 }
index 5832695..ef971bf 100644 (file)
@@ -10,7 +10,6 @@ details.  */
 
 package java.text;
 
-import java.io.Serializable;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -24,7 +23,7 @@ import java.util.ResourceBundle;
  * 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.
   public static final int DONE = -1;
index 30b746e..4280ea2 100644 (file)
@@ -10,7 +10,6 @@ details.  */
 
 package java.text;
 
-import java.io.Serializable;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -24,7 +23,7 @@ import java.util.ResourceBundle;
  * 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 CANONICAL_DECOMPOSITION = 1;
index d293790..9e73131 100644 (file)
@@ -89,6 +89,8 @@ public class GregorianCalendar extends Calendar {
     3600000 /* DST_OFFSET */
   };
 
+  private static final long serialVersionUID = -8125100834729963327L;
+
   public GregorianCalendar ()
   {
     this(null, null);
index 2f7a251..6360b99 100644 (file)
@@ -33,6 +33,8 @@ public class Properties extends Hashtable
 {
   protected Properties defaults;
 
+  private static final long serialVersionUID = 4112578634029874840L;
+
   public String getProperty (String propName)
     {
       return getProperty (propName, null);
index e4bac59..5ed4532 100644 (file)
@@ -26,15 +26,17 @@ import java.io.Serializable;
 public class Random implements Serializable
 {
   /* 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 */
   /* 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 */
   /* 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()
   {
index c7cb1c0..963513e 100644 (file)
@@ -71,4 +71,6 @@ public class Stack extends Vector
 
     return -1;
   }
+
+  private static final long serialVersionUID = 1224463164541339165L;
 }
index 02296d9..0145d72 100644 (file)
@@ -30,6 +30,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
 
   private static TimeZone zoneDefault;
 
+  private static final long serialVersionUID = 3581463369166924961L;
+
   public TimeZone ()
   {
   }
index 347d0ab..81178bf 100644 (file)
@@ -61,6 +61,8 @@ public class Vector implements Cloneable, Serializable
   /* The buffer in which elements of this vector are stored */
   protected Object[] elementData;
 
+  private static final long serialVersionUID = -2767605614048989439L;
+
   public Vector()
   {
     this(10, 0);