I'm using externalizable for my app; the objects involved have ArrayList(s) of nested objects. All objects involved implement Externalizable. However, the constructor for the objects referenced from the ArrayList(s) are not called; nor is readExternal for such objects. This is causing problems for version control.
Example:
class X implements Externalizable
{
static final long serialVersionUID = 1L;
int i;
ArrayList<Y> list;
... constructor, other code ...
public void writeExternal (ObjectOutput out)
{
out.writeLong (serialVersionUID);
out.writeInt (i);
out.writeObject (list);
}
public void readExternal (ObjectInput in)
{
long UID = in.readLong();
if (UID != serialVersionUID)
throw new InvalidClassException (UID);
i = in.readInt();
list = (ArrayList<Y>)in.readObject();
}
}
class Y implements Externalizable
{
static final long serialVersionUID = 1L;
int j;
... constructor, other code ...
public void writeExternal (ObjectOutput out)
{
out.writeLong (serialVersionUID);
out.writeInt (j);
}
public void readExternal (ObjectInput in)
{
long UID = in.readLong();
if (UID != serialVersionUID)
throw new InvalidClassException (UID);
j = in.readInt();
}
}
In this example, the constructor nor readExternal are called when X.readExternal executes.
Thanks in advance.