IonSystem ion = IonSystemBuilder.standard().build();
IonValueMapper ionValueMapper = new IonValueMapper(ion);
IonTimestamp timestamp = ion.newUtcTimestamp(new Date());
String serialized = ionValueMapper.writeValueAsString(timestamp);
// The next line fails with the ClassCastException
IonTimestamp restored = ionValueMapper.readValue(serialized, IonTimestamp.class);
To reproduce:
When deserializing an IonTimestamp, the IonParser returns a
com.amazon.ion.Timestamp
forgetEmbeddedObject()
, which the IonValueDeserializer attempts to cast to an IonValue.The above links also exhibit that this same problem exists for the
IonBlob
andIonClob
types (trying to cast abyte[]
to anIonValue
).