<Swing Dev> [8] Review request for 8027066: XMLDecoder in java 7 cannot properly deserialize object arrays
anton nashatyrev
anton.nashatyrev at oracle.com
Wed Oct 23 16:18:21 UTC 2013
Hello,
could you please review the following fix:
fix: http://cr.openjdk.java.net/~alitvinov/8027066/webrev.01
<http://cr.openjdk.java.net/%7Ealitvinov/8027066/webrev.01>
bug: https://bugs.openjdk.java.net/browse/JDK-8027066
The problem: when serializing-deserializing an object which fields refer
to the same array instance, one of the fields is not initialized
The reason: The ElementHandler.isArgument() returns false when the
serialized element contains 'id' which is our case since the second
object field refers the first field value by 'id':
<java version="1.7.0_45" class="java.beans.XMLDecoder">
<object class="XMLEncoderTests$Wrapper">
<void property="detailedMessages">
<array class="java.lang.String" length="2" id="StringArray0">
<void index="0">
<string>First message</string>
</void>
<void index="1">
<string>Second message</string>
</void>
</array>
</void>
<void property="messages">
<object idref="StringArray0"/>
</void>
</object>
</java>
When the isArgument() returns false the value created isn't passed up to
its parent. This issue resolved in the ObjectElementHandler by
overriding isArgument() to always return true. Though the same is not
done in the ArrayElementHandler.
The solution: override the isArgument() in the ArrayElementHandler the
same way as in ObjectElementHandler
Thanks!
Anton.
More information about the swing-dev
mailing list