commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI: Object serialization patch


From: Guilhem Lavaux
Subject: Re: FYI: Object serialization patch
Date: Sun, 22 Feb 2004 10:18:09 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

Michael Koch wrote:

Am Sonntag, 22. Februar 2004 09:49 schrieb Guilhem Lavaux:
Hi,

I am about to commit this fix concerning serialization in classpath.
It will solve again some problems with serialPersistentFields
(principally) which has been introduced by the former optimization
patch.

Please produce patches with diff "-bB" to ignore whitespace changes in the patch and to make it understandable more easy.

      {
-        System.loadLibrary("javaio");
+        System.loadLibrary("io");
      }

This looks just wrong for classpath.

Oops. Thank you very much.

Fixed in this patch.

Guilhem.

Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.38
diff -u -b -B -r1.38 ObjectInputStream.java
--- java/io/ObjectInputStream.java      10 Feb 2004 07:28:09 -0000      1.38
+++ java/io/ObjectInputStream.java      22 Feb 2004 09:14:51 -0000
@@ -513,7 +513,7 @@
        else
          {
            int comp_val =
-               real_fields[real_idx].compareTo (stream_fields[stream_idx]);
+               real_fields[real_idx].getName().compareTo 
(stream_fields[stream_idx].getName());
 
            if (comp_val < 0)
              {
@@ -527,21 +527,13 @@
              {
                stream_field = stream_fields[stream_idx++];
                real_field = real_fields[real_idx++];
-               if(stream_field.getType() != real_field.getType())
+               if (stream_field.getType() != real_field.getType())
                    throw new InvalidClassException
                        ("invalid field type for " + real_field.getName() +
                        " in class " + name);
              }
          }
-       if (stream_field != null)
-         {
-           if (stream_field.getOffset() < 0)
-               stream_field = null;
-           else if (!stream_field.isToSet())
-               real_field = null;
-         }
-       if (real_field != null && !real_field.isToSet())
-           real_field = null;
+
        /* If some of stream_fields does not correspond to any of real_fields,
         * or the opposite, then fieldmapping will go short.
         */
@@ -1576,12 +1568,11 @@
       {
        ObjectStreamField stream_field = fields[i];
        ObjectStreamField real_field = fields[i + 1];
-       if(stream_field != null || real_field != null)
-         {
-           boolean read_value = stream_field != null;
-           boolean set_value = real_field != null;
+       boolean read_value = (stream_field != null && stream_field.getOffset() 
>= 0 && stream_field.isToSet());
+       boolean set_value = (real_field != null && real_field.isToSet());
            String field_name;
            char type;
+
            if (stream_field != null)
              {
                field_name = stream_field.getName();
@@ -1680,8 +1671,8 @@
                  {
                    Object value =
                        read_value ? readObject() : null;
-                   if (set_value)
-                       real_field.setObjectField(obj, value);
+             if (set_value && stream_field != null)
+               real_field.setObjectField(obj, stream_field.getTypeString(), 
value);
                    break;
                  }
                default:
@@ -1689,7 +1680,6 @@
              }
          }
       }
-  }
 
   // Toggles writing primitive data to block-data buffer.
   private boolean setBlockDataMode (boolean on)
Index: java/io/ObjectStreamClass.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectStreamClass.java,v
retrieving revision 1.30
diff -u -b -B -r1.30 ObjectStreamClass.java
--- java/io/ObjectStreamClass.java      2 Feb 2004 10:26:51 -0000       1.30
+++ java/io/ObjectStreamClass.java      22 Feb 2004 09:14:51 -0000
@@ -344,6 +344,7 @@
                newFieldList[k] = exportedFields[j];
                newFieldList[k].setPersistent(true);
                newFieldList[k].setToSet(false);
+               newFieldList[k].lookupField(clazz);
                j++;
              }
            else
@@ -554,6 +555,19 @@
            if (fields != null)
              {
                Arrays.sort (fields);
+               // Retrieve field reference.
+               for (int i=0; i < fields.length; i++)
+                 {
+                   try
+                     {
+                       fields[i].lookupField(cl);
+                     }
+                   catch (NoSuchFieldException _)
+                     {
+                       fields[i].setToSet(false);
+                     }
+                 }
+               
                calculateOffsets();
                return;
              }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]