From ae066484dfc4edafddbcf5089720d8ceef28c232 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Fri, 23 Jul 2004 21:46:09 +0000 Subject: [PATCH] ObjectStreamField (ObjectStreamField): Don't unset 'toset' for final fields. 2004-07-23 Bryce McKinlay * java/io/ObjectStreamField (ObjectStreamField): Don't unset 'toset' for final fields. * testsuite/libjava.lang/Serialization.java: New test. * testsuite/libjava.lang/Serialization.out: New. From-SVN: r85096 --- libjava/ChangeLog | 9 +++++- libjava/java/io/ObjectStreamField.java | 1 - .../testsuite/libjava.lang/Serialization.java | 32 +++++++++++++++++++ .../testsuite/libjava.lang/Serialization.out | 3 ++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 libjava/testsuite/libjava.lang/Serialization.java create mode 100644 libjava/testsuite/libjava.lang/Serialization.out diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 502d3e867c2..8cb5ecb0dbb 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,4 +1,11 @@ -2004-07-23 Mark Wielaard +2004-07-23 Bryce McKinlay + + * java/io/ObjectStreamField (ObjectStreamField): Don't unset 'toset' for final + fields. + * testsuite/libjava.lang/Serialization.java: New test. + * testsuite/libjava.lang/Serialization.out: New. + +2004-07-23 Bryce McKinlay * gnu/java/net/DefaultContentHandlerFactory.java: Check in real file missed in last commit. diff --git a/libjava/java/io/ObjectStreamField.java b/libjava/java/io/ObjectStreamField.java index 830a349344a..ab7c934e48c 100644 --- a/libjava/java/io/ObjectStreamField.java +++ b/libjava/java/io/ObjectStreamField.java @@ -65,7 +65,6 @@ public class ObjectStreamField implements Comparable { this (field.getName(), field.getType()); this.field = field; - toset = !Modifier.isFinal(field.getModifiers()); } /** diff --git a/libjava/testsuite/libjava.lang/Serialization.java b/libjava/testsuite/libjava.lang/Serialization.java new file mode 100644 index 00000000000..81787533126 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Serialization.java @@ -0,0 +1,32 @@ +import java.io.*; +import java.util.*; + +public class Serialization +{ + public static void main(String[] args) + throws IOException, ClassNotFoundException + { + File f = new File("test.ser"); + ObjectOutputStream objStream = + new ObjectOutputStream(new FileOutputStream(f)); + objStream.writeInt(8); + objStream.writeObject(new Integer(99)); + List l = new LinkedList(); + l.add(new Integer(1)); + l.add(new Short((short) 7)); + l.add(new Float(9.95)); + l.add(new Long(-900000000000001l)); + l.add(new Double(-3.14159)); + l.add(new Character('X')); + l.add(new Byte((byte) 'z')); + objStream.writeObject(l); + objStream.close(); + + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f)); + System.out.println (ois.readInt()); + System.out.println (ois.readObject()); + System.out.println (ois.readObject()); + ois.close(); + f.delete(); + } +} diff --git a/libjava/testsuite/libjava.lang/Serialization.out b/libjava/testsuite/libjava.lang/Serialization.out new file mode 100644 index 00000000000..9c4e5d06c46 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Serialization.out @@ -0,0 +1,3 @@ +8 +99 +[1, 7, 9.95, -900000000000001, -3.14159, X, 122] -- 2.30.2