summaryrefslogtreecommitdiff
path: root/java/io/ObjectOutputStream.java
diff options
context:
space:
mode:
authorWarren Levy <warrenl@redhat.com>2000-10-06 00:03:07 +0000
committerWarren Levy <warrenl@redhat.com>2000-10-06 00:03:07 +0000
commita7d8d64aad0a4f47fadd3357a8ce2418691ab073 (patch)
treed3bb4bfc47da39e67d333e51e9b1af9614448ef7 /java/io/ObjectOutputStream.java
parent7ad017f4c67a9229ed891327a8107f994198b791 (diff)
downloadclasspath-a7d8d64aad0a4f47fadd3357a8ce2418691ab073.tar.gz
* Makefile.am: Removed Replaceable.java and Resolvable.java.
* ObjectInputStream.java (processResolution): Fixed typo in method name. (processResolution): Handle readResolve method via reflection with removal of Resolvable interface. * ObjectOutputStream.java (writeObject): Handle writeReplace method via reflection with removal of Replaceable interface. * Replaceable.java: Removed. * Resolvable.java: Removed. 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).
Diffstat (limited to 'java/io/ObjectOutputStream.java')
-rw-r--r--java/io/ObjectOutputStream.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/java/io/ObjectOutputStream.java b/java/io/ObjectOutputStream.java
index 545675952..33caa99c2 100644
--- a/java/io/ObjectOutputStream.java
+++ b/java/io/ObjectOutputStream.java
@@ -28,6 +28,9 @@ executable file might be covered by the GNU General Public License. */
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;
@@ -239,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);