From bf3478059df1a948c6b728754150d25b1d5610b1 Mon Sep 17 00:00:00 2001 From: Warren Levy Date: Thu, 5 Oct 2000 23:57:16 +0000 Subject: 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 --- libjava/java/io/ObjectOutputStream.java | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'libjava/java/io/ObjectOutputStream.java') 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); -- cgit v1.1