diff options
author | Warren Levy <warrenl@cygnus.com> | 2000-10-05 23:57:16 +0000 |
---|---|---|
committer | Warren Levy <warrenl@gcc.gnu.org> | 2000-10-05 23:57:16 +0000 |
commit | bf3478059df1a948c6b728754150d25b1d5610b1 (patch) | |
tree | ab6da2cb575ebc39dc451d7b89674a8d23e7af54 /libjava/java | |
parent | cc0cbae17ebe0b5c9a9152cd867d2ae5a5e943db (diff) | |
download | gcc-bf3478059df1a948c6b728754150d25b1d5610b1.zip gcc-bf3478059df1a948c6b728754150d25b1d5610b1.tar.gz gcc-bf3478059df1a948c6b728754150d25b1d5610b1.tar.bz2 |
Makefile.am: Removed java/io/Replaceable.java and java/io/Resolvable.java.
* Makefile.am: Removed java/io/Replaceable.java and
java/io/Resolvable.java.
* Makefile.in: Rebuilt.
* gcj/javaprims.h: Removed Replaceable and Resolvable from java.io
namespace.
* java/io/ObjectInputStream.java (processResolution): Fixed typo
in method name.
(processResolution): Handle readResolve method via reflection with
removal of Resolvable interface.
* java/io/ObjectOutputStream.java (writeObject): Handle writeReplace
method via reflection with removal of Replaceable interface.
* java/io/Replaceable.java: Removed.
* java/io/Resolvable.java: Removed.
* java/security/Key.java (serialVersionUID): New field.
* java/security/Provider.java (serialVersionUID): New field.
* java/security/interfaces/DSAPrivateKey.java (serialVersionUID):
New field.
* java/security/interfaces/DSAPublicKey.java (serialVersionUID):
New field.
* java/sql/DataTruncation.java (serialVersionUID): New field.
* java/sql/SQLException.java (serialVersionUID): New field.
* java/sql/SQLWarning.java (serialVersionUID): New field.
* java/util/Date.java (serialVersionUID): New field.
(millis): Made transient.
(readObject): New method.
(writeObject): New method.
Serialization mods.
Note: The interfaces java.io.Replaceable and java.io.Resolvable were only
temporary additions to JDK 1.2 beta versions and were not included
in the JDK 1.2 final. The Serialization spec instructs how to deal
with their methods (via reflection).
From-SVN: r36736
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/io/ObjectInputStream.java | 36 | ||||
-rw-r--r-- | libjava/java/io/ObjectOutputStream.java | 27 | ||||
-rw-r--r-- | libjava/java/io/Replaceable.java | 54 | ||||
-rw-r--r-- | libjava/java/io/Resolvable.java | 52 | ||||
-rw-r--r-- | libjava/java/security/Key.java | 3 | ||||
-rw-r--r-- | libjava/java/security/Provider.java | 4 | ||||
-rw-r--r-- | libjava/java/security/interfaces/DSAPrivateKey.java | 3 | ||||
-rw-r--r-- | libjava/java/security/interfaces/DSAPublicKey.java | 3 | ||||
-rw-r--r-- | libjava/java/sql/DataTruncation.java | 4 | ||||
-rw-r--r-- | libjava/java/sql/SQLException.java | 4 | ||||
-rw-r--r-- | libjava/java/sql/SQLWarning.java | 4 | ||||
-rw-r--r-- | libjava/java/util/Date.java | 33 |
12 files changed, 95 insertions, 132 deletions
diff --git a/libjava/java/io/ObjectInputStream.java b/libjava/java/io/ObjectInputStream.java index 53353dc..c1d6d6c 100644 --- a/libjava/java/io/ObjectInputStream.java +++ b/libjava/java/io/ObjectInputStream.java @@ -1,5 +1,5 @@ /* ObjectInputStream.java -- Class used to read serialized objects - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,6 +37,7 @@ import gnu.java.io.ObjectIdentityWrapper; import gnu.java.lang.reflect.TypeSignature; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; @@ -189,7 +190,7 @@ public class ObjectInputStream extends InputStream { // DEBUG ("STRING "); String s = this.realInputStream.readUTF (); - ret_val = processResoultion (s, assignNewHandle (s)); + ret_val = processResolution (s, assignNewHandle (s)); break; } @@ -202,7 +203,7 @@ public class ObjectInputStream extends InputStream Object array = Array.newInstance (componenetType, length); int handle = assignNewHandle (array); readArrayElements (array, componenetType); - ret_val = processResoultion (array, handle); + ret_val = processResolution (array, handle); break; } @@ -250,7 +251,7 @@ public class ObjectInputStream extends InputStream if (read_from_blocks) setBlockDataMode (false); - ret_val = processResoultion (obj, handle); + ret_val = processResolution (obj, handle); break; } // end if (Externalizable.class.isAssignableFrom (clazz)) @@ -315,7 +316,7 @@ public class ObjectInputStream extends InputStream this.currentObject = null; this.currentObjectStreamClass = null; - ret_val = processResoultion (obj, handle); + ret_val = processResolution (obj, handle); break; } @@ -937,11 +938,30 @@ public class ObjectInputStream extends InputStream } - private Object processResoultion (Object obj, int handle) + private Object processResolution (Object obj, int handle) throws IOException { - if (obj instanceof Resolvable) - obj = ((Resolvable)obj).readResolve (); + if (obj instanceof Serializable) + { + Method m = null; + try + { + Class classArgs[] = {}; + m = obj.getClass ().getDeclaredMethod ("readResolve", classArgs); + // m can't be null by definition since an exception would + // have been thrown so a check for null is not needed. + obj = m.invoke (obj, new Object[] {}); + } + catch (NoSuchMethodException ignore) + { + } + catch (IllegalAccessException ignore) + { + } + catch (InvocationTargetException ignore) + { + } + } if (this.resolveEnabled) obj = resolveObject (obj); diff --git a/libjava/java/io/ObjectOutputStream.java b/libjava/java/io/ObjectOutputStream.java index 664b882..cd6202e 100644 --- a/libjava/java/io/ObjectOutputStream.java +++ b/libjava/java/io/ObjectOutputStream.java @@ -30,6 +30,7 @@ package java.io; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import gnu.java.io.ObjectIdentityWrapper; @@ -241,13 +242,33 @@ public class ObjectOutputStream extends OutputStream Object replacedObject = null; - if ((replacementEnabled || obj instanceof Replaceable) + if ((replacementEnabled || obj instanceof Serializable) && ! replaceDone) { replacedObject = obj; - if (obj instanceof Replaceable) - obj = ((Replaceable)obj).writeReplace (); + if (obj instanceof Serializable) + { + Method m = null; + try + { + Class classArgs[] = {}; + m = obj.getClass ().getDeclaredMethod ("writeReplace", + classArgs); + // m can't be null by definition since an exception would + // have been thrown so a check for null is not needed. + obj = m.invoke (obj, new Object[] {}); + } + catch (NoSuchMethodException ignore) + { + } + catch (IllegalAccessException ignore) + { + } + catch (InvocationTargetException ignore) + { + } + } if (replacementEnabled) obj = replaceObject (obj); diff --git a/libjava/java/io/Replaceable.java b/libjava/java/io/Replaceable.java deleted file mode 100644 index 1035ab5..0000000 --- a/libjava/java/io/Replaceable.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Replaceable.java -- Replace an object with another object - Copyright (C) 1998 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 java.io; - -/** - * This interface is used to indicate that an object may want to have - * another object serialized instead of itself. It contains one method - * that is to be called when an object is to be serialized. That method - * is reponsible for returning the real object that should be serialized - * instead of object being queried. - * - * @version 0.0 - * - * @author Aaron M. Renn (arenn@urbanophile.com) - */ -public interface Replaceable extends Serializable -{ - -/** - * This method returns the object that should be serialized instead of - * this object - * - * @return The real object that should be serialized - */ -public abstract Object -writeReplace(); - -} // interface Replaceable - diff --git a/libjava/java/io/Resolvable.java b/libjava/java/io/Resolvable.java deleted file mode 100644 index b7250de6..0000000 --- a/libjava/java/io/Resolvable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* Resolvable.java -- Returns an object to replace the one being de-serialized - Copyright (C) 1998 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 java.io; - -/** - * This interface is implemented when an object wishes to return another - * object to replace it during de-serialization. It has one method that - * returns the object that should be used to replace the original object. - * - * @version 0.0 - * - * @author Aaron M. Renn (arenn@urbanophile.com) - */ -public interface Resolvable extends Serializable -{ - -/** - * This method returns the object that should be used to replace the - * original object during de-serialization. - * - * @return The replacement object - */ -public abstract Object -readResolve(); - -} // interface Resolvable - diff --git a/libjava/java/security/Key.java b/libjava/java/security/Key.java index b3f2bef..ae73bf6 100644 --- a/libjava/java/security/Key.java +++ b/libjava/java/security/Key.java @@ -20,8 +20,7 @@ import java.io.Serializable; public interface Key extends Serializable { - // FIXME: need to set this at some point when serialization is implemented. - // public static final long serialVersionUID = 0L; + public static final long serialVersionUID = 6603384152749567654L; public String getAlgorithm(); public String getFormat(); diff --git a/libjava/java/security/Provider.java b/libjava/java/security/Provider.java index d0a969f..fbaa3c0 100644 --- a/libjava/java/security/Provider.java +++ b/libjava/java/security/Provider.java @@ -1,5 +1,5 @@ /* Provider.java -- Security provider information - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -68,6 +68,8 @@ private String name; */ private double version; +private static final long serialVersionUID = -4298000515446427739L; + /*************************************************************************/ /* diff --git a/libjava/java/security/interfaces/DSAPrivateKey.java b/libjava/java/security/interfaces/DSAPrivateKey.java index c0efe21b4..5d70136 100644 --- a/libjava/java/security/interfaces/DSAPrivateKey.java +++ b/libjava/java/security/interfaces/DSAPrivateKey.java @@ -21,8 +21,7 @@ import java.math.BigInteger; public interface DSAPrivateKey extends DSAKey, PrivateKey { - // FIXME: need to set this at some point when serialization is implemented. - // public static final long serialVersionUID = 0L; + public static final long serialVersionUID = 7776497482533790279L; public BigInteger getX(); } diff --git a/libjava/java/security/interfaces/DSAPublicKey.java b/libjava/java/security/interfaces/DSAPublicKey.java index 43eedaf..a8bb885 100644 --- a/libjava/java/security/interfaces/DSAPublicKey.java +++ b/libjava/java/security/interfaces/DSAPublicKey.java @@ -21,8 +21,7 @@ import java.math.BigInteger; public interface DSAPublicKey extends DSAKey, PublicKey { - // FIXME: need to set this at some point when serialization is implemented. - // public static final long serialVersionUID = 0L; + public static final long serialVersionUID = 1234526332779022332L; public BigInteger getY(); } diff --git a/libjava/java/sql/DataTruncation.java b/libjava/java/sql/DataTruncation.java index bb9ada6..eabd46c 100644 --- a/libjava/java/sql/DataTruncation.java +++ b/libjava/java/sql/DataTruncation.java @@ -1,5 +1,5 @@ /* DataTruncation.java -- Warning when data has been truncated. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -72,6 +72,8 @@ private boolean read; */ private int transferSize; +private static final long serialVersionUID = 6464298989504059473L; + /*************************************************************************/ /* diff --git a/libjava/java/sql/SQLException.java b/libjava/java/sql/SQLException.java index 0fa6483..650d3c6 100644 --- a/libjava/java/sql/SQLException.java +++ b/libjava/java/sql/SQLException.java @@ -1,5 +1,5 @@ /* SQLException.java -- General SQL exception - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -59,6 +59,8 @@ private String SQLState; */ private int vendorCode; +private static final long serialVersionUID = 2135244094396331484L; + /*************************************************************************/ /* diff --git a/libjava/java/sql/SQLWarning.java b/libjava/java/sql/SQLWarning.java index d13bad1..0318262 100644 --- a/libjava/java/sql/SQLWarning.java +++ b/libjava/java/sql/SQLWarning.java @@ -1,5 +1,5 @@ /* SQLWarning.java -- Database access warnings. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -132,5 +132,7 @@ setNextWarning(SQLWarning e) super.setNextException(e); } +private static final long serialVersionUID = 3917336774604784856L; + } // class SQLWarning diff --git a/libjava/java/util/Date.java b/libjava/java/util/Date.java index 6a8a765..4b76b8a 100644 --- a/libjava/java/util/Date.java +++ b/libjava/java/util/Date.java @@ -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. @@ -18,13 +18,13 @@ import java.text.*; * "The Java Language Specification", ISBN 0-201-63451-1, * and O'Reilly's "Java in a Nutshell". * Status: Need to re-write toString(). - * Missing: ToGMTString and toLocaleString. - * Serialization spec: Specifies readObject/writeObject. + * Missing: ToGMTString. */ - public class Date implements java.io.Serializable, Cloneable { - private long millis; + private static final long serialVersionUID = 7523967970034938905L; + + transient private long millis; public Date() { millis = System.currentTimeMillis(); } @@ -480,4 +480,27 @@ public class Date implements java.io.Serializable, Cloneable cal.set(year+1900, month, date, hours, minutes, seconds); return cal.getTimeInMillis(); } + + /** + * Reads an Object from the stream. + */ + private void readObject (java.io.ObjectInputStream input) + throws java.io.IOException, ClassNotFoundException + { + input.defaultReadObject (); + millis = input.readLong (); + } + + /** + * Writes an Object to the stream. + * @serialdata A long value representing the offset from the epoch + * in milliseconds. This is the same value that is returned by the + * method getTime(). + */ + private void writeObject (java.io.ObjectOutputStream output) + throws java.io.IOException + { + output.defaultWriteObject (); + output.writeLong (millis); + } } |