Hi Geoff,

Geoff Groos wrote:

> I'm on XStream 1.4.7 (I'll get myself current in a moment)
> 
> I'm looking at line 67 of the AbstractReferenceUnmarshaller where it's
> putting the integer `10` in as a value for the reference-key
> ".../myModelMatrixClass/widthOfMatrix". The field corresponding to that
> path is an 'int'.
> 
> the myModelMatrix type does use a custom converter which extends the
> ReflectionConverter, but it uses the stock `unmarshalField` method to
> unmarshall that field, which in turn is hitting the
> 'abstractReferenceUnmarshaller' to unmarshall the '10' value at the
> element <widthOfMatrix>10</widthOfMatrix>
> 
> I hope I'm describing this accurately. I could start putting together an
> SSCCE if it would help.

OK. My bad, I've looked at the marshaller only. Basically you're right, but 
if we throw away the references for immutables, we might introduce a 
compatibility problem:

==================== %< =========================
UUID[] uuidArray = new UUID[2];
uuidArray[0] = uuidArray[1] = UUID.randomUUID();
XStream xstream = new XStream();
String xml = xstream.toXML(uuidArray);

// unmarshal in later version of application with a changed setup:
XStream xstream = new XStream();
xstrea.addImmutable(UUID.class);
xstream.fromXML(xml); // XStreamException, reference not found
==================== %< =========================

See, I've already set UUID as immutable for 1.4.9. If we drop also the 
references to any immutable, anybody with an XML containing a reference to a 
UUID will fail at deserialization. :-/

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to