Details
-
Type: Bug
-
Status: Closed
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
JDK version and platform:JSE5 with Eclipse 3.2
Description
If you instanceate an object of the class below, it will write a stream of itselfe into a file.
This stream is basically the GregorianCalendar.
Unfortunatly XStream writes way too many lines of XML (Attached at the end):
This stream is then no longer deserializable and throws an exception.
class XStreamTest extends GregorianCalendar
{
public XStreamTest() throws IllegalArgumentException, IllegalAccessException, IOException
public void writeToFile() throws IllegalArgumentException, IllegalAccessException, IOException
{ XStream _xstream = new XStream(); ObjectOutputStream out = _xstream.createObjectOutputStream( new FileWriter( "XmlStream.xml" )); out.writeObject( this ); out.close(); }};
Outcome:
<object-stream>
<com.abdalla.bushnaq.rac.configuration.Hallo serialization="custom">
<gregorian-calendar>
<default>
<areFieldsSet>true</areFieldsSet>
<firstDayOfWeek>2</firstDayOfWeek>
<isTimeSet>true</isTimeSet>
<lenient>true</lenient>
<minimalDaysInFirstWeek>4</minimalDaysInFirstWeek>
<nextStamp>2</nextStamp>
<serialVersionOnStream>1</serialVersionOnStream>
<time>1155123829984</time>
<fields>
<int>1</int>
<int>2006</int>
<int>7</int>
<int>32</int>
<int>2</int>
<int>9</int>
<int>221</int>
<int>4</int>
<int>2</int>
<int>1</int>
<int>1</int>
<int>13</int>
<int>43</int>
<int>49</int>
<int>984</int>
<int>3600000</int>
<int>3600000</int>
</fields>
<isSet>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
<boolean>true</boolean>
</isSet>
<zone class="java.util.SimpleTimeZone" serialization="custom">
<java.util.TimeZone>
<default>
<ID>Europe/Berlin</ID>
</default>
</java.util.TimeZone>
<java.util.SimpleTimeZone>
<default>
<dstSavings>3600000</dstSavings>
<endDay>-1</endDay>
<endDayOfWeek>1</endDayOfWeek>
<endMode>2</endMode>
<endMonth>9</endMonth>
<endTime>10800000</endTime>
<endTimeMode>2</endTimeMode>
<rawOffset>3600000</rawOffset>
<serialVersionOnStream>2</serialVersionOnStream>
<startDay>-1</startDay>
<startDayOfWeek>1</startDayOfWeek>
<startMode>2</startMode>
<startMonth>2</startMonth>
<startTime>7200000</startTime>
<startTimeMode>2</startTimeMode>
<startYear>0</startYear>
<useDaylight>true</useDaylight>
<monthLength>HxwfHh8eHx8eHx4f</monthLength>
</default>
<int>6</int>
<byte-array>/wH/AQIC</byte-array>
<int-array>
<int>3600000</int>
<int>3600000</int>
</int-array>
</java.util.SimpleTimeZone>
</zone>
</default>
<sun.util.calendar.ZoneInfo serialization="custom">
<java.util.TimeZone>
<default>
<ID>Europe/Berlin</ID>
</default>
</java.util.TimeZone>
<sun.util.calendar.ZoneInfo>
<default>
<checksum>-300950473</checksum>
<dstSavings>3600000</dstSavings>
<rawOffset>3600000</rawOffset>
<rawOffsetDiff>0</rawOffsetDiff>
<willGMTOffsetChange>false</willGMTOffsetChange>
<offsets>
<int>3600000</int>
<int>7200000</int>
<int>3600000</int>
<int>10800000</int>
</offsets>
<simpleTimeZoneParams>
<int>2</int>
<int>-1</int>
<int>1</int>
<int>3600000</int>
<int>2</int>
<int>9</int>
<int>-1</int>
<int>1</int>
<int>3600000</int>
<int>2</int>
</simpleTimeZoneParams>
<transitions>
<long>-9048018124800000</long>
<long>-6937421414399967</long>
<long>-6883260825600000</long>
<long>-6813514137599967</long>
<long>-6759014400000000</long>
<long>-6684696575999967</long>
<long>-6630196838400000</long>
<long>-3845755699199967</long>
<long>-3511325491200000</long>
<long>-3459303014399967</long>
<long>-3392416972800000</long>
<long>-3328008191999967</long>
<long>-3263599411200000</long>
<long>-3199190630399967</long>
<long>-3180802867199981</long>
<long>-3137273855999967</long>
<long>-3117794918400000</long>
<long>-3065772441599967</long>
<long>-3003487027200000</long>
<long>-2939432140799967</long>
<long>-2927045836799981</long>
<long>-2909719756799967</long>
<long>-2875023360000000</long>
<long>-2805660057599967</long>
<long>-2746205798400000</long>
<long>-2679319756799967</long>
<long>-2617388236800000</long>
<long>1326410956800033</long>
<long>1388342476800000</long>
<long>1452751257600033</long>
<long>1517160038400000</long>
<long>1581568819200033</long>
<long>1645977600000000</long>
<long>1710386380800033</long>
<long>1774795161600000</long>
<long>1839203942400033</long>
<long>1906089984000000</long>
<long>1970498764800033</long>
<long>2034907545600000</long>
<long>2099316326400033</long>
<long>2163725107200000</long>
<long>2228133888000033</long>
<long>2292542668800000</long>
<long>2356951449600033</long>
<long>2421360230400000</long>
<long>2485769011200033</long>
<long>2550177792000000</long>
<long>2614586572800033</long>
<long>2681472614400000</long>
<long>2745881395200033</long>
<long>2810290176000000</long>
<long>2874698956800033</long>
<long>2939107737600000</long>
<long>3003516518400033</long>
<long>3067925299200000</long>
<long>3132334080000033</long>
<long>3196742860800000</long>
<long>3261151641600033</long>
<long>3325560422400000</long>
<long>3392446464000033</long>
<long>3466764288000000</long>
<long>3521264025600033</long>
<long>3595581849600000</long>
<long>3650081587200033</long>
<long>3724399411200000</long>
<long>3778899148800033</long>
<long>3855694233600000</long>
<long>3907716710400033</long>
<long>3984511795200000</long>
<long>4036534272000033</long>
<long>4113329356800000</long>
<long>4167829094400033</long>
<long>4242146918400000</long>
<long>4296646656000033</long>
<long>4370964480000000</long>
<long>4425464217600033</long>
<long>4502259302400000</long>
<long>4554281779200033</long>
<long>4631076864000000</long>
<long>4683099340800033</long>
<long>4759894425600000</long>
<long>4811916902400033</long>
<long>4888711987200000</long>
<long>4943211724800033</long>
<long>5017529548800000</long>
<long>5072029286400033</long>
<long>5146347110400000</long>
<long>5200846848000033</long>
<long>5277641932800000</long>
<long>5329664409600033</long>
<long>5406459494400000</long>
<long>5458481971200033</long>
<long>5535277056000000</long>
<long>5589776793600033</long>
<long>5664094617600000</long>
<long>5718594355200033</long>
<long>5792912179200000</long>
<long>5847411916800033</long>
<long>5921729740800000</long>
<long>5976229478400033</long>
<long>6053024563200000</long>
<long>6105047040000033</long>
<long>6181842124800000</long>
<long>6233864601600033</long>
<long>6310659686400000</long>
<long>6365159424000033</long>
<long>6439477248000000</long>
<long>6493976985600033</long>
<long>6568294809600000</long>
<long>6622794547200033</long>
<long>6699589632000000</long>
<long>6751612108800033</long>
<long>6828407193600000</long>
<long>6880429670400033</long>
<long>6957224755200000</long>
<long>7011724492800033</long>
<long>7086042316800000</long>
<long>7140542054400033</long>
<long>7214859878400000</long>
<long>7269359616000033</long>
<long>7343677440000000</long>
<long>7398177177600033</long>
<long>7474972262400000</long>
<long>7526994739200033</long>
<long>7603789824000000</long>
<long>7655812300800033</long>
<long>7732607385600000</long>
<long>7787107123200033</long>
<long>7861424947200000</long>
<long>7915924684800033</long>
<long>7990242508800000</long>
<long>8044742246400033</long>
<long>8121537331200000</long>
<long>8173559808000033</long>
<long>8250354892800000</long>
<long>8302377369600033</long>
<long>8379172454400000</long>
<long>8431194931200033</long>
<long>8507990016000000</long>
<long>8562489753600033</long>
<long>8636807577600000</long>
<long>8691307315200033</long>
<long>8765625139200000</long>
</transitions>
</default>
</sun.util.calendar.ZoneInfo>
</sun.util.calendar.ZoneInfo>
</gregorian-calendar>
<gregorian-calendar>
<default>
<gregorianCutover>-12219292800000</gregorianCutover>
</default>
</gregorian-calendar>
</com.abdalla.bushnaq.rac.configuration.Hallo>
</object-stream>
XStream comes with a GregorianCalendarConverter. If you derive from a GregorianCalendar you must create a custom Converter on your own, which is in your case quite easy:
We cannot simply hande any derived GregorianCalendars on our own, since we do not know, if the derived class introduces new elements. OTOH we don't want to create special converters for com.sun.* classes, that might not be portable.
Please, ask the next time on the user's list first.