I want to update my JfreeChart 1.0.9 to 1.0.19. In my application I save some Objects via serialization in a zip and to load it I deserialize it again. (simple) Now when I update JFreeChart to the new version the DataRange Class of JfreeChart cause me trouble.
I get this error:
Errror occured while importing a project: java.io.InvalidClassException: org.jfree.data.time.DateRange; incompatible types for field lowerDate
I analyse the class of DateRange and also find the problem.
DateRange.java 1.0.9:
public class DateRange extends Range implements Serializable {
/** For serialization. */
private static final long serialVersionUID = -4705682568375418157L;
/** The lower bound for the range. */
private Date lowerDate;
/** The upper bound for the range. */
private Date upperDate;
...
DateRange.java 1.0.19:
public class DateRange extends Range implements Serializable {
/** For serialization. */
private static final long serialVersionUID = -4705682568375418157L;
/** The lower bound for the range. */
private long lowerDate;
/** The upper bound for the range. */
private long upperDate;
...
You should see the problem. The type of the field lowerDate and upperDate change from java.util.Date to long. Now I can't deserialize existing project again. (for new project it isn't a problem)
Do you have a solution how to fix it?
My only idea to fix it, is to modify the source and add following method to the DateRange.java explained here: Serialization
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
}
But I don't want to modify jfreechart when it's possible.
I solved it myself. I changed the DateRange.java and modify the type of lowerDate and upperDate from long to Date. (it's not very nice solution)
With the readObject it didn't work because I get an EOFException when I deserialize the other objects.
When somebody have a better solution I would like to hear it.