2004-02-28 Guilhem Lavaux <guilhem@kaffe.org>
* java/io/ObjectInputStream.java (readClassDescriptor): Keep elements of the mapping non null. (checkTypeConsistency): New method. (readFields): Fixed main loop and base logic. Small reindentation. * java/io/ObjectStreamField.java (lookupField): New method to update the field reference. (checkFieldType): New method. * java/io/ObjectStreamClass.java (setClass, setFields): Call lookupField when building the field database. Check the real field type. From-SVN: r78627
This commit is contained in:
parent
ca67f27850
commit
646e329010
4 changed files with 317 additions and 173 deletions
|
@ -327,7 +327,7 @@ public class ObjectStreamClass implements Serializable
|
|||
i = 0; j = 0; k = 0;
|
||||
while (i < fields.length && j < exportedFields.length)
|
||||
{
|
||||
int comp = fields[i].getName().compareTo(exportedFields[j].getName());
|
||||
int comp = fields[i].compareTo(exportedFields[j]);
|
||||
|
||||
if (comp < 0)
|
||||
{
|
||||
|
@ -344,10 +344,27 @@ public class ObjectStreamClass implements Serializable
|
|||
newFieldList[k] = exportedFields[j];
|
||||
newFieldList[k].setPersistent(true);
|
||||
newFieldList[k].setToSet(false);
|
||||
try
|
||||
{
|
||||
newFieldList[k].lookupField(clazz);
|
||||
newFieldList[k].checkFieldType();
|
||||
}
|
||||
catch (NoSuchFieldException _)
|
||||
{
|
||||
}
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
exportedFields[j].lookupField(clazz);
|
||||
exportedFields[j].checkFieldType();
|
||||
}
|
||||
catch (NoSuchFieldException _)
|
||||
{
|
||||
}
|
||||
|
||||
if (!fields[i].getType().equals(exportedFields[j].getType()))
|
||||
throw new InvalidClassException
|
||||
("serialPersistentFields must be compatible with" +
|
||||
|
@ -554,6 +571,19 @@ outer:
|
|||
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;
|
||||
}
|
||||
|
@ -798,7 +828,7 @@ outer:
|
|||
|
||||
fieldsArray = new ObjectStreamField[ o.length ];
|
||||
System.arraycopy(o, 0, fieldsArray, 0, o.length);
|
||||
|
||||
|
||||
return fieldsArray;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue